Skip to content

Commit 4b702d2

Browse files
committed
refactor: put this file into bin instead of src
1 parent 9bd0636 commit 4b702d2

File tree

8 files changed

+21
-13
lines changed

8 files changed

+21
-13
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
22
/*/
33
!/build/
4-
!/src/cli.js
4+
!/bin/cli.js
55
CONTRIBUTION.md

src/cli.js renamed to bin/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import { readFile, writeFile } from 'node:fs/promises';
99
import path from 'node:path';
1010
import process from 'node:process';
11-
import { buildTimeTransform } from './index.js';
11+
import { buildTimeTransform } from '../src/index.js';
1212

1313
const help = `
1414
CSS if() Build-time Transformation CLI
1515
1616
Usage:
1717
npx css-if-transform <input.css> [output.css] [options]
18-
node src/cli.js <input.css> [output.css] [options]
18+
node bin/cli.js <input.css> [output.css] [options]
1919
2020
Options:
2121
--minify Minify the output CSS

css-if-polyfill-0.0.1.tgz

56.1 KB
Binary file not shown.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Maximilian Franzke",
1515
"license": "MIT",
1616
"bin": {
17-
"css-if-transform": "./src/cli.js"
17+
"css-if-transform": "./bin/cli.js"
1818
},
1919
"main": "dist/index.cjs",
2020
"types": "dist/index.d.ts",
@@ -32,8 +32,8 @@
3232
}
3333
},
3434
"files": [
35+
"bin/cli.js",
3536
"dist/",
36-
"src/cli.js",
3737
"README.md",
3838
"LICENSE"
3939
],

test/cli.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('CLI Tool', () => {
3333

3434
test('transforms CSS file with output to file', async () => {
3535
const { stdout } = await execAsync(
36-
`node src/cli.js ${testInputFile} ${testOutputFile} --stats`
36+
`node bin/cli.js ${testInputFile} ${testOutputFile} --stats`
3737
);
3838

3939
expect(stdout).toContain('Reading CSS from');
@@ -49,7 +49,7 @@ describe('CLI Tool', () => {
4949

5050
test('outputs to stdout when no output file specified', async () => {
5151
const { stdout } = await execAsync(
52-
`node src/cli.js ${testInputFile} --stats`
52+
`node bin/cli.js ${testInputFile} --stats`
5353
);
5454

5555
expect(stdout).toContain('Transformation Statistics');
@@ -58,7 +58,7 @@ describe('CLI Tool', () => {
5858
});
5959

6060
test('shows help when no arguments provided', async () => {
61-
const { stdout } = await execAsync('node src/cli.js --help');
61+
const { stdout } = await execAsync('node bin/cli.js --help');
6262

6363
expect(stdout).toContain('CSS if() Build-time Transformation CLI');
6464
expect(stdout).toContain('Usage:');
@@ -67,7 +67,7 @@ describe('CLI Tool', () => {
6767

6868
test('handles minification option', async () => {
6969
const { stdout } = await execAsync(
70-
`node src/cli.js ${testInputFile} ${testOutputFile} --minify --stats`
70+
`node bin/cli.js ${testInputFile} ${testOutputFile} --minify --stats`
7171
);
7272

7373
expect(stdout).toContain('CSS was minified');
@@ -79,7 +79,7 @@ describe('CLI Tool', () => {
7979

8080
test('handles non-existent input file gracefully', async () => {
8181
try {
82-
await execAsync('node src/cli.js non-existent.css');
82+
await execAsync('node bin/cli.js non-existent.css');
8383
expect.fail('Should have thrown an error');
8484
} catch (error) {
8585
expect(error.stdout || error.stderr).toContain('Error');

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"outDir": "./dist",
1212
"rootDir": "./src"
1313
},
14-
"include": ["src/**/*"],
14+
"include": ["src/**/*", "bin/cli.js"],
1515
"exclude": ["node_modules", "dist", "test"]
1616
}

xo.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ const xoConfig = [
55
rules: {
66
'import-x/order': 0 // We use a prettier plugin to organize imports
77
}
8+
},
9+
// Provide an overwrite for bin/cli.js to not check for n/no-unpublished-bin rule
10+
// This is needed because the bin/cli.js file is actually published to npm, so it seems to be a false positive
11+
{
12+
files: ['bin/cli.js'],
13+
rules: {
14+
'n/no-unpublished-bin': 0
15+
}
816
}
917
];
1018

0 commit comments

Comments
 (0)