Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 1c90298

Browse files
committed
feat(cssx.mjs): add --log arg
1 parent 3ce0d93 commit 1c90298

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

bin/cssx.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ import { execSync } from 'child_process';
44
import { join } from 'path';
55

66
try {
7-
if (process.argv.includes('--compile'))
7+
const typecheck = process.argv.includes('--compile');
8+
if (typecheck)
89
console.log('Running TypeScript compiler...'),
910
execSync('npx tsc --noEmit --incremental false', {
1011
stdio: 'inherit',
1112
cwd: process.cwd(),
1213
});
1314
else console.log('pre compile run...');
14-
15-
execSync('npx tsx compiler/src/index.ts', {
15+
const argv = process.argv.includes('--log') ? ' --log' : '';
16+
execSync('npx tsx compiler/src/index.ts' + argv, {
1617
stdio: 'inherit',
1718
cwd: join(process.cwd(), 'node_modules/typedcssx'),
1819
});
19-
20-
console.log('Compilation completed successfully.');
20+
const completed = typecheck ? 'completed ' : '';
21+
console.log(`Compilation ${completed}successfully`);
2122
} catch (error) {
2223
console.error('Compilation failed:', error.message);
2324
process.exit(1);

src/_internal/utils/build-in.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@ export const buildIn = (styleSheet: string, global?: string): void => {
1717
const cssData = fs.readFileSync(filePath, 'utf-8');
1818
if (!cssData.includes(styleSheet)) {
1919
fs.appendFileSync(filePath, styleSheet, 'utf-8');
20-
console.log(message + styleSheet);
2120
}
22-
} else {
23-
fs.appendFileSync(filePath, styleSheet, 'utf-8');
24-
console.log(message + styleSheet);
21+
if (process.argv.includes('--log')) console.log(message + styleSheet);
2522
}
2623
} catch (error) {
2724
console.error('Error writing to file:', error);
28-
console.error('Stack trace:', error);
2925
}
3026
};

0 commit comments

Comments
 (0)