🔧 Global formatting and update formatting
This commit is contained in:
8
bin/utils/combine.ts
vendored
8
bin/utils/combine.ts
vendored
@@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
|
||||
export default async function combineFiles(files: string[], output: string) {
|
||||
const contents = files.map(file => {
|
||||
const contents = files.map((file) => {
|
||||
const fileContent = fs.readFileSync(file);
|
||||
if (file.endsWith('.css')) {
|
||||
return (
|
||||
@@ -11,7 +11,11 @@ export default async function combineFiles(files: string[], output: string) {
|
||||
);
|
||||
}
|
||||
|
||||
return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent + ' });';
|
||||
return (
|
||||
"window.addEventListener('DOMContentLoaded', (_event) => { " +
|
||||
fileContent +
|
||||
' });'
|
||||
);
|
||||
});
|
||||
fs.writeFileSync(output, contents.join('\n'));
|
||||
return files;
|
||||
|
||||
11
bin/utils/info.ts
vendored
11
bin/utils/info.ts
vendored
@@ -5,11 +5,18 @@ import chalk from 'chalk';
|
||||
|
||||
// Generates an identifier based on the given URL.
|
||||
export function getIdentifier(url: string) {
|
||||
const postFixHash = crypto.createHash('md5').update(url).digest('hex').substring(0, 6);
|
||||
const postFixHash = crypto
|
||||
.createHash('md5')
|
||||
.update(url)
|
||||
.digest('hex')
|
||||
.substring(0, 6);
|
||||
return `com.pake.${postFixHash}`;
|
||||
}
|
||||
|
||||
export async function promptText(message: string, initial?: string): Promise<string> {
|
||||
export async function promptText(
|
||||
message: string,
|
||||
initial?: string,
|
||||
): Promise<string> {
|
||||
const response = await prompts({
|
||||
type: 'text',
|
||||
name: 'content',
|
||||
|
||||
4
bin/utils/ip.ts
vendored
4
bin/utils/ip.ts
vendored
@@ -13,13 +13,13 @@ const ping = async (host: string) => {
|
||||
|
||||
// Prevent timeouts from affecting user experience.
|
||||
const requestPromise = new Promise<number>((resolve, reject) => {
|
||||
const req = http.get(`http://${ip.address}`, res => {
|
||||
const req = http.get(`http://${ip.address}`, (res) => {
|
||||
const delay = new Date().getTime() - start.getTime();
|
||||
res.resume();
|
||||
resolve(delay);
|
||||
});
|
||||
|
||||
req.on('error', err => {
|
||||
req.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
6
bin/utils/shell.ts
vendored
6
bin/utils/shell.ts
vendored
@@ -5,10 +5,12 @@ export async function shellExec(command: string) {
|
||||
try {
|
||||
const { exitCode } = await execa(command, {
|
||||
cwd: npmDirectory,
|
||||
stdio: 'inherit'
|
||||
stdio: 'inherit',
|
||||
});
|
||||
return exitCode;
|
||||
} catch (error) {
|
||||
throw new Error(`Error occurred while executing command "${command}". Exit code: ${error.exitCode}`);
|
||||
throw new Error(
|
||||
`Error occurred while executing command "${command}". Exit code: ${error.exitCode}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user