Comparing version
@@ -11,22 +11,18 @@ #!/usr/bin/env node | ||
program | ||
.arguments('<filename>') | ||
.version(version) | ||
.usage('[options] <filename>') | ||
.option('--es6-mixedImports') | ||
.option('-t, --type <type>', 'The type of content being passed in. Useful if you want to use a non-js detective') | ||
.parse(process.argv); | ||
.option('--es6-mixed-imports', 'Fetch all dependendies from a file that contains both CJS and ES6 imports') | ||
.option('-t, --type <type>', 'The type of content being passed in. Useful if you want to use a non-JS detective') | ||
.parse(); | ||
const content = fs.readFileSync(program.args[0], 'utf8'); | ||
const cliOptions = program.opts(); | ||
const options = { | ||
es6: {} | ||
es6: { | ||
mixedImports: Boolean(cliOptions.es6MixedImports) | ||
}, | ||
type: cliOptions.type | ||
}; | ||
if (program.es6MixedImports) { | ||
options.es6.mixedImports = true; | ||
} | ||
const content = fs.readFileSync(program.args[0], 'utf8'); | ||
if (program.type) { | ||
options.type = program.type; | ||
} | ||
console.log(precinct(content, options).join('\n')); |
23
index.js
@@ -5,4 +5,4 @@ 'use strict'; | ||
const path = require('path'); | ||
const { debuglog } = require('util'); | ||
const debug = require('debug')('precinct'); | ||
const getModuleType = require('module-definition'); | ||
@@ -21,2 +21,3 @@ const Walker = require('node-source-walk'); | ||
const debug = debuglog('precinct'); | ||
const natives = process.binding('natives'); | ||
@@ -33,2 +34,4 @@ | ||
function precinct(content, options = {}) { | ||
debug('options given: %o', options); | ||
let dependencies = []; | ||
@@ -38,10 +41,2 @@ let ast; | ||
// Legacy form backCompat where type was the second parameter | ||
if (typeof options === 'string') { | ||
type = options; | ||
options = {}; | ||
} | ||
debug('options given: %o', options); | ||
// We assume we're dealing with a JS file | ||
@@ -112,2 +107,4 @@ if (!type && typeof content !== 'object') { | ||
break; | ||
default: | ||
// nothing | ||
} | ||
@@ -143,6 +140,3 @@ | ||
precinct.paperwork = (filename, options = {}) => { | ||
options = { | ||
includeCore: true, | ||
...options | ||
}; | ||
options = { includeCore: true, ...options }; | ||
@@ -160,6 +154,5 @@ const fileSystem = options.fileSystem || fs; | ||
type = 'commonjs'; | ||
} | ||
// We need to sniff the JS module to find its type, not by extension | ||
// Other possible types pass through normally | ||
else if (ext !== '.js' && ext !== '.jsx') { | ||
} else if (ext !== '.js' && ext !== '.jsx') { | ||
debug('paperwork: stripping the dot from the extension to serve as the type'); | ||
@@ -166,0 +159,0 @@ type = ext.replace('.', ''); |
{ | ||
"name": "precinct", | ||
"version": "8.3.1", | ||
"version": "9.0.0", | ||
"description": "Unleash the detectives", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "jscs index.js test/index.js", | ||
"lint": "eslint index.js test/index.js", | ||
"mocha": "mocha test/index.js", | ||
"test": "npm run lint && npm run mocha" | ||
"test": "npm run lint && npm run mocha", | ||
"test:ci": "c8 npm run mocha" | ||
}, | ||
@@ -34,3 +35,3 @@ "bin": { | ||
"engines": { | ||
"node": "^10.13 || ^12 || >=14" | ||
"node": "^12.20.0 || ^14.14.0 || >=16.0.0" | ||
}, | ||
@@ -43,23 +44,22 @@ "files": [ | ||
"dependencies": { | ||
"commander": "^2.20.3", | ||
"debug": "^4.3.3", | ||
"detective-amd": "^3.1.0", | ||
"detective-cjs": "^3.1.1", | ||
"detective-es6": "^2.2.1", | ||
"commander": "^9.1.0", | ||
"detective-amd": "^4.0.1", | ||
"detective-cjs": "^4.0.0", | ||
"detective-es6": "^3.0.0", | ||
"detective-less": "^1.0.2", | ||
"detective-postcss": "^4.0.0", | ||
"detective-sass": "^3.0.1", | ||
"detective-scss": "^2.0.1", | ||
"detective-stylus": "^1.0.0", | ||
"detective-typescript": "^7.0.0", | ||
"module-definition": "^3.3.1", | ||
"node-source-walk": "^4.2.0" | ||
"detective-postcss": "^6.0.1", | ||
"detective-sass": "^4.0.1", | ||
"detective-scss": "^3.0.0", | ||
"detective-stylus": "^2.0.0", | ||
"detective-typescript": "^9.0.0", | ||
"module-definition": "^4.0.0", | ||
"node-source-walk": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"jscs": "^3.0.7", | ||
"jscs-preset-mrjoelkemp": "^2.0.0", | ||
"mocha": "^8.4.0", | ||
"rewire": "^5.0.0", | ||
"sinon": "^9.2.4" | ||
"c8": "^7.11.0", | ||
"eslint": "^8.11.0", | ||
"mocha": "^9.2.2", | ||
"rewire": "^6.0.0", | ||
"sinon": "^13.0.1" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9765
2.34%12
-7.69%92
17.95%168
-4.55%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated