-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default function (options) { | ||
console.log('hi from js preprocessor'); | ||
return options; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default function (options) { | ||
console.log('hi from ts preprocessor'); | ||
return options; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "@fixtures/cli-preprocessor" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function () { | ||
console.log('hi from js reporter'); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function () { | ||
console.log('hi from ts reporter'); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "@fixtures/cli-reporter" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "@fixtures/cli" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import assert from 'node:assert/strict'; | ||
import { execSync } from 'node:child_process'; | ||
import test from 'node:test'; | ||
import { resolve } from '../src/util/path.js'; | ||
|
||
const cwd = resolve('fixtures/cli-preprocessor'); | ||
|
||
const exec = (command: string) => { | ||
const output = execSync(command.replace(/^knip/, 'node ../../dist/cli.js'), { cwd }); | ||
return output.toString().trim(); | ||
}; | ||
|
||
test('knip --preprocessor ./index.js', () => { | ||
assert.equal(exec('knip --preprocessor ./index.js'), 'hi from js preprocessor'); | ||
}); | ||
|
||
test('knip --preprocessor ./index.ts', () => { | ||
assert.equal(exec('knip --preprocessor ./index.ts'), 'hi from ts preprocessor'); | ||
}); | ||
|
||
test('knip --preprocessor knip-preprocessor', () => { | ||
assert.equal(exec('knip --preprocessor knip-preprocessor'), 'hi from pkg preprocessor'); | ||
}); | ||
|
||
test('knip --preprocessor @org/preprocessor', () => { | ||
assert.equal(exec('knip --preprocessor @org/preprocessor'), 'hi from scoped preprocessor'); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import assert from 'node:assert/strict'; | ||
import { execSync } from 'node:child_process'; | ||
import test from 'node:test'; | ||
import { resolve } from '../src/util/path.js'; | ||
|
||
const cwd = resolve('fixtures/cli-reporter'); | ||
|
||
const exec = (command: string) => { | ||
const output = execSync(command.replace(/^knip/, 'node ../../dist/cli.js'), { cwd }); | ||
return output.toString().trim(); | ||
}; | ||
|
||
test('knip --reporter ./index.js', () => { | ||
assert.equal(exec('knip --reporter ./index.js'), 'hi from js reporter'); | ||
}); | ||
|
||
test('knip --reporter ./index.ts', () => { | ||
assert.equal(exec('knip --reporter ./index.ts'), 'hi from ts reporter'); | ||
}); | ||
|
||
test('knip --reporter knip-reporter', () => { | ||
assert.equal(exec('knip --reporter knip-reporter'), 'hi from pkg reporter'); | ||
}); | ||
|
||
test('knip --reporter @org/reporter', () => { | ||
assert.equal(exec('knip --reporter @org/reporter'), 'hi from scoped reporter'); | ||
}); |