knip
Version:
Find and fix unused files, dependencies and exports in your TypeScript and JavaScript projects
29 lines (28 loc) • 945 B
JavaScript
import { toEntry, toProductionEntry } from '../../util/input.js';
const title = 'Node.js';
const isEnabled = () => true;
const config = ['package.json'];
const packageJsonPath = (id) => id;
const resolveEntryPaths = localConfig => {
const scripts = localConfig.scripts;
const entries = [toProductionEntry('server.js')];
if (scripts && Object.keys(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(scripts[script]))) {
const patterns = ['**/*{.,-,_}test.?(c|m)js', '**/test-*.?(c|m)js', '**/test.?(c|m)js', '**/test/**/*.?(c|m)js'];
entries.push(...patterns.map(toEntry));
}
return entries;
};
const args = {
positional: true,
nodeImportArgs: true,
resolve: ['test-reporter'],
args: (args) => args.filter(arg => !/--test-reporter[= ](spec|tap|dot|junit|lcov)/.test(arg)),
};
export default {
title,
isEnabled,
packageJsonPath,
config,
resolveEntryPaths,
args,
};