Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

precinct

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

precinct - npm Package Compare versions

Comparing version 8.3.0 to 8.3.1

15

bin/cli.js

@@ -5,8 +5,9 @@ #!/usr/bin/env node

var precinct = require('../');
var program = require('commander');
var fs = require('fs');
const fs = require('fs');
const program = require('commander');
const precinct = require('../index.js');
const { version } = require('../package.json');
program
.version(require('../package.json').version)
.version(version)
.usage('[options] <filename>')

@@ -17,9 +18,9 @@ .option('--es6-mixedImports')

var content = fs.readFileSync(program.args[0], 'utf8');
const content = fs.readFileSync(program.args[0], 'utf8');
var options = {
const options = {
es6: {}
};
if (program['es6MixedImports']) {
if (program.es6MixedImports) {
options.es6.mixedImports = true;

@@ -26,0 +27,0 @@ }

@@ -1,20 +0,22 @@

var getModuleType = require('module-definition');
var debug = require('debug')('precinct');
var Walker = require('node-source-walk');
'use strict';
var detectiveCjs = require('detective-cjs');
var detectiveAmd = require('detective-amd');
var detectiveEs6 = require('detective-es6');
var detectiveLess = require('detective-less');
var detectivePostcss = require('detective-postcss');
var detectiveSass = require('detective-sass');
var detectiveScss = require('detective-scss');
var detectiveStylus = require('detective-stylus');
var detectiveTypeScript = require('detective-typescript');
const fs = require('fs');
const path = require('path');
var fs = require('fs');
var path = require('path');
const debug = require('debug')('precinct');
const getModuleType = require('module-definition');
const Walker = require('node-source-walk');
var natives = process.binding('natives');
const detectiveAmd = require('detective-amd');
const detectiveCjs = require('detective-cjs');
const detectiveEs6 = require('detective-es6');
const detectiveLess = require('detective-less');
const detectivePostcss = require('detective-postcss');
const detectiveSass = require('detective-sass');
const detectiveScss = require('detective-scss');
const detectiveStylus = require('detective-stylus');
const detectiveTypeScript = require('detective-typescript');
const natives = process.binding('natives');
/**

@@ -29,5 +31,5 @@ * Finds the list of dependencies for the given file

function precinct(content, options = {}) {
var dependencies = [];
var ast;
var type = options.type;
let dependencies = [];
let ast;
let type = options.type;

@@ -40,3 +42,3 @@ // Legacy form backCompat where type was the second parameter

debug('options given: ', options);
debug('options given: %o', options);

@@ -46,3 +48,3 @@ // We assume we're dealing with a JS file

debug('we assume this is JS');
var walker = new Walker();
const walker = new Walker();

@@ -54,6 +56,6 @@ try {

precinct.ast = ast;
} catch (e) {
} catch (error) {
// In case a previous call had it populated
precinct.ast = null;
debug('could not parse content: %s', e.message);
debug('could not parse content: %s', error.message);
return dependencies;

@@ -71,6 +73,6 @@ }

type = type || getModuleType.fromSource(ast);
debug('module type: ', type);
debug('module type: %s', type);
var theDetective;
var mixedMode = options.es6 && options.es6.mixedImports;
let theDetective;
const mixedMode = options.es6 && options.es6.mixedImports;

@@ -116,3 +118,3 @@ switch (type) {

} else {
debug('no detective found for: ' + type);
debug('no detective found for: %s', type);
}

@@ -141,11 +143,12 @@

*/
precinct.paperwork = function(filename, options = {}) {
options = Object.assign({
includeCore: true
}, options);
precinct.paperwork = (filename, options = {}) => {
options = {
includeCore: true,
...options
};
var fileSystem = options.fileSystem || fs;
var content = fileSystem.readFileSync(filename, 'utf8');
var ext = path.extname(filename);
var type;
const fileSystem = options.fileSystem || fs;
const content = fileSystem.readFileSync(filename, 'utf8');
const ext = path.extname(filename);
let type;

@@ -172,11 +175,6 @@ if (ext === '.styl') {

debug('paperwork: invoking precinct');
var deps = precinct(content, options);
const deps = precinct(content, options);
if (!options.includeCore) {
return deps.filter(function(d) {
if (d.startsWith('node:')) {
return false;
}
return !natives[d];
});
return deps.filter((dep) => dep.startsWith('node:') ? false : !natives[dep]);
}

@@ -183,0 +181,0 @@

{
"name": "precinct",
"version": "8.3.0",
"version": "8.3.1",
"description": "Unleash the detectives",
"main": "index.js",
"scripts": {
"test": "jscs index.js test/index.js && mocha test/index.js"
"lint": "jscs index.js test/index.js",
"mocha": "mocha test/index.js",
"test": "npm run lint && npm run mocha"
},

@@ -14,3 +16,3 @@ "bin": {

"type": "git",
"url": "git@github.com:mrjoelkemp/node-precinct.git"
"url": "git@github.com:dependents/node-precinct.git"
},

@@ -30,3 +32,3 @@ "keywords": [

"bugs": {
"url": "https://github.com/mrjoelkemp/node-precinct/issues"
"url": "https://github.com/dependents/node-precinct/issues"
},

@@ -36,9 +38,13 @@ "engines": {

},
"homepage": "https://github.com/mrjoelkemp/node-precinct",
"files": [
"bin/cli.js",
"index.js"
],
"homepage": "https://github.com/dependents/node-precinct",
"dependencies": {
"commander": "^2.20.3",
"debug": "^4.3.1",
"detective-amd": "^3.0.1",
"debug": "^4.3.3",
"detective-amd": "^3.1.0",
"detective-cjs": "^3.1.1",
"detective-es6": "^2.2.0",
"detective-es6": "^2.2.1",
"detective-less": "^1.0.2",

@@ -54,8 +60,8 @@ "detective-postcss": "^4.0.0",

"devDependencies": {
"jscs": "~3.0.7",
"jscs-preset-mrjoelkemp": "~2.0.0",
"mocha": "^8.2.1",
"jscs": "^3.0.7",
"jscs-preset-mrjoelkemp": "^2.0.0",
"mocha": "^8.4.0",
"rewire": "^5.0.0",
"sinon": "^9.2.1"
"sinon": "^9.2.4"
}
}

@@ -1,2 +0,2 @@

### Precinct [![npm](http://img.shields.io/npm/v/precinct.svg)](https://npmjs.org/package/precinct) [![npm](http://img.shields.io/npm/dm/precinct.svg)](https://npmjs.org/package/precinct)
### Precinct [![CI](https://github.com/dependents/node-precinct/actions/workflows/ci.yml/badge.svg)](https://github.com/dependents/node-precinct/actions/workflows/ci.yml) [![npm](http://img.shields.io/npm/dm/precinct.svg)](https://npmjs.org/package/precinct)

@@ -19,8 +19,8 @@ > Unleash the detectives

```js
var precinct = require('precinct');
const precinct = require('precinct');
var content = fs.readFileSync('myFile.js', 'utf8');
const content = fs.readFileSync('myFile.js', 'utf8');
// Pass in a file's content or an AST
var deps = precinct(content);
const deps = precinct(content);
```

@@ -45,6 +45,6 @@

```js
var content = fs.readFileSync('styles.scss', 'utf8');
const content = fs.readFileSync('styles.scss', 'utf8');
var deps = precinct(content, { type: 'sass' });
var deps2 = precinct(content, { type: 'stylus' });
const deps = precinct(content, { type: 'sass' });
const deps2 = precinct(content, { type: 'stylus' });
```

@@ -55,6 +55,6 @@

```js
var paperwork = require('precinct').paperwork;
const { paperwork } = require('precinct');
var deps = paperwork('myFile.js');
var deps2 = paperwork('styles.scss');
const deps = paperwork('myFile.js');
const deps2 = paperwork('styles.scss');
```

@@ -61,0 +61,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc