Comparing version 0.2.6 to 0.3.0
{ | ||
"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", |
@@ -323,3 +323,3 @@ # ShellJS - Unix shell commands for Node.js [![Build Status](https://secure.travis-ci.org/arturadib/shelljs.png)](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. |
@@ -88,2 +88,6 @@ // | ||
//@include ./src/ln | ||
var _ln = require('./src/ln'); | ||
exports.ln = common.wrap('ln', _ln); | ||
//@ | ||
@@ -90,0 +94,0 @@ //@ ### exit(code) |
@@ -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); |
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. */ |
@@ -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') |
@@ -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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80205
38
1934
570
1
29