| var fs = require('fs'); | ||
| var spawn = require('child_process').spawn; | ||
| var when = require('when'); | ||
| function checkAvailable(){ | ||
| var pkgName = JSON.parse(fs.readFileSync('./package.json', 'utf-8')).name; | ||
| var defer = when.defer(); | ||
| var result = ''; | ||
| var cmd = 'npm'; | ||
| var args = ['view', pkgName]; | ||
| if(process.platform === 'win32'){ | ||
| args.unshift('/c', cmd); | ||
| cmd = 'cmd'; | ||
| } | ||
| var child = spawn(cmd, args); | ||
| child.stderr.setEncoding('utf8'); | ||
| child.stderr.on('data', function(data){ | ||
| result += data; | ||
| }); | ||
| child.on('close', function(code){ | ||
| defer.resolve(result); | ||
| }); | ||
| return defer.promise; | ||
| } | ||
| module.exports = checkAvailable; |
+4
-0
@@ -12,2 +12,6 @@ var spawn = require('child_process').spawn; | ||
| var args = command.slice(1); | ||
| if(process.platform === 'win32'){ | ||
| args.unshift('/c', cmd); | ||
| cmd = 'cmd'; | ||
| } | ||
@@ -14,0 +18,0 @@ if(cmd !== 'npm'){ |
+1
-1
| { | ||
| "name": "yfnm", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "Learn to make an NPM module", | ||
@@ -5,0 +5,0 @@ "preferGlobal": true, |
+0
-2
@@ -6,4 +6,2 @@ var instructions = require('../instructions'); | ||
| var fs = require('fs'); | ||
| var spawn = require('child_process').spawn; | ||
| var when = require('when'); | ||
@@ -10,0 +8,0 @@ module.exports = function(){ |
+5
-16
| var instructions = require('../instructions'); | ||
| var question = require('../question'); | ||
| var checkAvailable = require('../check-available'); | ||
| var fs = require('fs'); | ||
| var spawn = require('child_process').spawn; | ||
| var when = require('when'); | ||
| module.exports = function(){ | ||
@@ -12,15 +9,7 @@ instructions('Publish Your Package', 'publish_packages'); | ||
| return question('{underline}Challenge{/underline}: Publish your package', function(data){ | ||
| var pkgName = JSON.parse(fs.readFileSync('./package.json', 'utf-8')).name; | ||
| var defer = when.defer(); | ||
| var result = ''; | ||
| var child = spawn('npm', ['view', pkgName]); | ||
| child.stderr.setEncoding('utf8'); | ||
| child.stderr.on('data', function(data){ | ||
| result += data; | ||
| }); | ||
| child.on('close', function(code){ | ||
| defer.resolve(!(new RegExp('is not in the npm registry').test(result))); | ||
| }); | ||
| return defer.promise; | ||
| return checkAvailable() | ||
| .then(function(result){ | ||
| return !(new RegExp('is not in the npm registry').test(result)); | ||
| }); | ||
| }); | ||
| }; |
+5
-16
| var instructions = require('../instructions'); | ||
| var question = require('../question'); | ||
| var checkAvailable = require('../check-available'); | ||
| var fs = require('fs'); | ||
| var spawn = require('child_process').spawn; | ||
| var when = require('when'); | ||
| module.exports = function(){ | ||
@@ -16,15 +13,7 @@ instructions('Naming Your Package', 'naming_packages'); | ||
| var pkgName = JSON.parse(fs.readFileSync('./package.json', 'utf-8')).name; | ||
| var defer = when.defer(); | ||
| var result = ''; | ||
| var child = spawn('npm', ['view', pkgName]); | ||
| child.stderr.setEncoding('utf8'); | ||
| child.stderr.on('data', function(data){ | ||
| result += data; | ||
| }); | ||
| child.on('close', function(code){ | ||
| defer.resolve(new RegExp('is not in the npm registry').test(result)); | ||
| }); | ||
| return defer.promise; | ||
| return checkAvailable() | ||
| .then(function(result){ | ||
| return new RegExp('is not in the npm registry').test(result); | ||
| }); | ||
| }); | ||
| }; |
+4
-0
@@ -12,2 +12,6 @@ var spawn = require('child_process').spawn; | ||
| var args = command.slice(1); | ||
| if(process.platform === 'win32'){ | ||
| args.unshift('/c', cmd); | ||
| cmd = 'cmd'; | ||
| } | ||
@@ -14,0 +18,0 @@ if(cmd !== 'npm'){ |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
18466
0.32%41
2.5%338
3.05%12
-7.69%4
-33.33%