shelljs-plugin-open
Advanced tools
Comparing version 0.1.1 to 0.1.2
22
index.js
@@ -5,4 +5,4 @@ // This exposes the plugin utilities | ||
// Require whatever modules you need for your project | ||
var child = require('child_process'); | ||
var fs = require('fs'); | ||
var opener = require('opener'); | ||
var pathExists = require('path-exists'); | ||
@@ -14,15 +14,11 @@ // Implement your command in a function, which accepts `options` as the | ||
if (!fs.existsSync(fileName) && !fileName.match(URL_REGEX)) { | ||
if (!pathExists.sync(fileName) && !fileName.match(URL_REGEX)) { | ||
plugin.error('Unable to locate file: ' + fileName); | ||
} | ||
var cmd; | ||
if (process.platform.match(/^win/)) | ||
cmd = 'start'; | ||
else if (process.platform.match(/^linux/)) | ||
cmd = 'xdg-open'; | ||
else // assume it's Mac OS X, which uses `open` | ||
cmd = 'open'; | ||
child.exec(cmd + ' ' + JSON.stringify(fileName)); | ||
var proc = opener(fileName); | ||
proc.unref(); | ||
proc.stdin.unref(); | ||
proc.stdout.unref(); | ||
proc.stderr.unref(); | ||
return ''; | ||
@@ -33,5 +29,3 @@ } | ||
plugin.register('open', open, { | ||
globStart: 1, // Start globbing at the first non-option argument | ||
cmdOptions: {}, // There are no supported options for this command | ||
wrapOutput: true, // Wrap the output in a ShellString | ||
}); | ||
@@ -38,0 +32,0 @@ |
{ | ||
"name": "shelljs-plugin-open", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "An example shelljs-plugin to open a file with its default application", | ||
@@ -41,3 +41,7 @@ "main": "index.js", | ||
"shelljs": "^0.7.3" | ||
}, | ||
"dependencies": { | ||
"opener": "^1.4.1", | ||
"path-exists": "^3.0.0" | ||
} | ||
} |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
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
0
0
3124
3
3
25
2
0
+ Addedopener@^1.4.1
+ Addedpath-exists@^3.0.0
+ Addedopener@1.5.2(transitive)
+ Addedpath-exists@3.0.0(transitive)