+53
| var fs = require('fs'); | ||
| var path = require('path'); | ||
| var common = require('./common'); | ||
| var os = require('os'); | ||
| //@ | ||
| //@ ### ln(options, source, dest) | ||
| //@ ### ln(source, dest) | ||
| //@ Available options: | ||
| //@ | ||
| //@ + `s`: symlink | ||
| //@ + `f`: force | ||
| //@ | ||
| //@ Examples: | ||
| //@ | ||
| //@ ```javascript | ||
| //@ ln('file', 'newlink'); | ||
| //@ ln('-sf', 'file', 'existing'); | ||
| //@ ``` | ||
| //@ | ||
| //@ Links source to dest. Use -f to force the link, should dest already exist. | ||
| function _ln(options, source, dest) { | ||
| options = common.parseOptions(options, { | ||
| 's': 'symlink', | ||
| 'f': 'force' | ||
| }); | ||
| if (!source || !dest) { | ||
| common.error('Missing <source> and/or <dest>'); | ||
| } | ||
| source = path.resolve(process.cwd(), String(source)); | ||
| dest = path.resolve(process.cwd(), String(dest)); | ||
| if (!fs.existsSync(source)) { | ||
| common.error('Source file does not exist', true); | ||
| } | ||
| if (fs.existsSync(dest)) { | ||
| if (!options.force) { | ||
| common.error('Destination file exists', true); | ||
| } | ||
| fs.unlinkSync(dest); | ||
| } | ||
| if (options.symlink) { | ||
| fs.symlinkSync(source, dest, os.platform() === "win32" ? "junction" : null); | ||
| } else { | ||
| fs.linkSync(source, dest, os.platform() === "win32" ? "junction" : null); | ||
| } | ||
| } | ||
| module.exports = _ln; |
+2
-1
| { | ||
| "name": "shelljs", | ||
| "version": "0.2.6", | ||
| "version": "0.3.0", | ||
| "author": "Artur Adib <aadib@mozilla.com>", | ||
@@ -18,2 +18,3 @@ "description": "Portable Unix shell commands for Node.js", | ||
| }, | ||
| "license": "BSD*", | ||
| "homepage": "http://github.com/arturadib/shelljs", | ||
@@ -20,0 +21,0 @@ "main": "./shell.js", |
+19
-2
@@ -323,3 +323,3 @@ # ShellJS - Unix shell commands for Node.js [](http://travis-ci.org/arturadib/shelljs) | ||
| ### sed([options ,] search_regex, replace_str, file) | ||
| ### sed([options ,] search_regex, replacement, file) | ||
| Available options: | ||
@@ -337,3 +337,3 @@ | ||
| Reads an input string from `file` and performs a JavaScript `replace()` on the input | ||
| using the given search regex and replacement string. Returns the new string after replacement. | ||
| using the given search regex and replacement string or function. Returns the new string after replacement. | ||
@@ -444,2 +444,19 @@ | ||
| ### ln(options, source, dest) | ||
| ### ln(source, dest) | ||
| Available options: | ||
| + `s`: symlink | ||
| + `f`: force | ||
| Examples: | ||
| ```javascript | ||
| ln('file', 'newlink'); | ||
| ln('-sf', 'file', 'existing'); | ||
| ``` | ||
| Links source to dest. Use -f to force the link, should dest already exist. | ||
| ### exit(code) | ||
@@ -446,0 +463,0 @@ Exits the current process with the given exit code. |
+4
-0
@@ -88,2 +88,6 @@ // | ||
| //@include ./src/ln | ||
| var _ln = require('./src/ln'); | ||
| exports.ln = common.wrap('ln', _ln); | ||
| //@ | ||
@@ -90,0 +94,0 @@ //@ ### exit(code) |
+16
-2
@@ -95,4 +95,18 @@ var os = require('os'); | ||
| list.forEach(function(listEl) { | ||
| // Wildcard present? | ||
| if (listEl.search(/\*/) > -1) { | ||
| // Wildcard present on directory names ? | ||
| if(listEl.search(/\*[^\/]*\//) > -1 || listEl.search(/\*\*[^\/]*\//) > -1) { | ||
| var match = listEl.match(/^([^*]+\/|)(.*)/); | ||
| var root = match[1]; | ||
| var rest = match[2]; | ||
| var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*"); | ||
| restRegex = new RegExp(restRegex); | ||
| _ls('-R', root).filter(function (e) { | ||
| return restRegex.test(e); | ||
| }).forEach(function(file) { | ||
| expanded.push(file); | ||
| }); | ||
| } | ||
| // Wildcard present on file names ? | ||
| else if (listEl.search(/\*/) > -1) { | ||
| _ls('', listEl).forEach(function(file) { | ||
@@ -99,0 +113,0 @@ expanded.push(file); |
+2
-1
| var fs = require('fs'); | ||
| var path = require('path'); | ||
| var common = require('./common'); | ||
| var os = require('os'); | ||
@@ -75,3 +76,3 @@ // Buffered file copy, synchronous | ||
| var symlinkFull = fs.readlinkSync(srcFile); | ||
| fs.symlinkSync(symlinkFull, destFile); | ||
| fs.symlinkSync(symlinkFull, destFile, os.platform() === "win32" ? "junction" : null); | ||
| } else { | ||
@@ -78,0 +79,0 @@ /* At this point, we've hit a file actually worth copying... so copy it on over. */ |
+3
-3
@@ -5,3 +5,3 @@ var common = require('./common'); | ||
| //@ | ||
| //@ ### sed([options ,] search_regex, replace_str, file) | ||
| //@ ### sed([options ,] search_regex, replacement, file) | ||
| //@ Available options: | ||
@@ -19,3 +19,3 @@ //@ | ||
| //@ Reads an input string from `file` and performs a JavaScript `replace()` on the input | ||
| //@ using the given search regex and replacement string. Returns the new string after replacement. | ||
| //@ using the given search regex and replacement string or function. Returns the new string after replacement. | ||
| function _sed(options, regex, replacement, file) { | ||
@@ -26,3 +26,3 @@ options = common.parseOptions(options, { | ||
| if (typeof replacement === 'string') | ||
| if (typeof replacement === 'string' || typeof replacement === 'function') | ||
| replacement = replacement; // no-op | ||
@@ -29,0 +29,0 @@ else if (typeof replacement === 'number') |
+9
-5
@@ -18,2 +18,6 @@ var common = require('./common'); | ||
| function checkPath(path) { | ||
| return fs.existsSync(path) && fs.statSync(path).isDirectory() == false; | ||
| } | ||
| //@ | ||
@@ -46,3 +50,3 @@ //@ ### which(command) | ||
| var attempt = path.resolve(dir + '/' + cmd); | ||
| if (fs.existsSync(attempt)) { | ||
| if (checkPath(attempt)) { | ||
| where = attempt; | ||
@@ -55,3 +59,3 @@ return; | ||
| attempt = baseAttempt + '.exe'; | ||
| if (fs.existsSync(attempt)) { | ||
| if (checkPath(attempt)) { | ||
| where = attempt; | ||
@@ -61,3 +65,3 @@ return; | ||
| attempt = baseAttempt + '.cmd'; | ||
| if (fs.existsSync(attempt)) { | ||
| if (checkPath(attempt)) { | ||
| where = attempt; | ||
@@ -67,3 +71,3 @@ return; | ||
| attempt = baseAttempt + '.bat'; | ||
| if (fs.existsSync(attempt)) { | ||
| if (checkPath(attempt)) { | ||
| where = attempt; | ||
@@ -77,3 +81,3 @@ return; | ||
| // Command not found anywhere? | ||
| if (!fs.existsSync(cmd) && !where) | ||
| if (!checkPath(cmd) && !where) | ||
| return null; | ||
@@ -80,0 +84,0 @@ |
Misc. License Issues
LicenseA package's licensing information has fine-grained problems.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
80205
2.99%38
2.7%1934
3.53%570
3.07%1
Infinity%33
3.13%