Skip to content

Commit 5ef462c

Browse files
committedAug 31, 2021
chore: Modify the output log.
1 parent 9f8dabe commit 5ef462c

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed
 

‎packages/tsbb/.bin/tsbb

-3
This file was deleted.

‎packages/tsbb/src/utils/compile.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ export async function compile(
3333
if (isMatch(item.path, ['**/*.[jt]s?(x)']) && !isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)', '**/*.d.ts'])) {
3434
transform(item.path, { entryDir, cjs, ...other });
3535
} else {
36-
await copyFiles(item.path, cjsPath);
36+
copyFiles(item.path, cjsPath);
3737
}
3838
}
3939
if (esm) {
4040
const esmPath = item.path.replace(entryDir, esm);
4141
if (isMatch(item.path, ['**/*.[jt]s?(x)']) && !isMatch(item.path, ['**/?(*.)+(spec|test).[jt]s?(x)', '**/*.d.ts'])) {
4242
transform(item.path, { entryDir, esm, ...other });
4343
} else {
44-
await copyFiles(item.path, esmPath);
44+
copyFiles(item.path, esmPath);
4545
}
4646
}
4747
}),

‎packages/tsbb/src/utils/output.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,30 @@ export async function outputFiles(filename: string, code: string, sourceMap?: Ba
1212
outputLog(filename);
1313
}
1414

15-
export async function copyFiles(src: string, dest: string) {
16-
await FS.copy(src, dest);
15+
export function copyFiles(src: string, dest: string) {
16+
FS.copySync(src, dest);
1717
outputLog(dest);
1818
}
1919

2020
export function outputLog(filename: string) {
21+
const pkg = getPkg();
2122
const extname = path.extname(filename).replace('.', '');
23+
const name = `\x1b[35m ${pkg.name}\x1b[0m`;
2224
if (/\.map$/.test(filename)) {
23-
console.log(`♻️ \x1b[36;1m MAP\x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
25+
console.log(`♻️ ${name}\x1b[36;1m MAP\x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
2426
} else if (/d.ts$/.test(filename)) {
25-
console.log(`♻️ \x1b[34;1m DTS\x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
27+
console.log(`♻️ ${name}\x1b[34;1m DTS\x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
2628
} else if (extname == 'css') {
27-
console.log(`♻️ \x1b[35;1m CSS \x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
29+
console.log(`♻️ ${name}\x1b[35;1m CSS \x1b[0m┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
2830
} else if (extname == 'js') {
29-
console.log(`♻️ \x1b[33;1m JS \x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
31+
console.log(`♻️ ${name}\x1b[33;1m JS \x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
3032
} else {
31-
console.log(`♻️ \x1b[37;1m ${(extname || '***').toLocaleUpperCase()} \x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
33+
console.log(`♻️ ${name}\x1b[37;1m ${(extname || '***').toLocaleUpperCase()} \x1b[0m ┈┈▶ \x1b[32;1m${filename}\x1b[0m`);
3234
}
3335
}
36+
37+
function getPkg() {
38+
const dir = ts.sys.getCurrentDirectory();
39+
const pkgPath = path.resolve(dir, 'package.json');
40+
return FS.readJSONSync(pkgPath) || {};
41+
}

0 commit comments

Comments
 (0)
Please sign in to comment.