aboutsummaryrefslogtreecommitdiff
path: root/cordova/node_modules/shelljs/src/sed.js
diff options
context:
space:
mode:
Diffstat (limited to 'cordova/node_modules/shelljs/src/sed.js')
-rwxr-xr-xcordova/node_modules/shelljs/src/sed.js43
1 files changed, 0 insertions, 43 deletions
diff --git a/cordova/node_modules/shelljs/src/sed.js b/cordova/node_modules/shelljs/src/sed.js
deleted file mode 100755
index 65f7cb4..0000000
--- a/cordova/node_modules/shelljs/src/sed.js
+++ /dev/null
@@ -1,43 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-
-//@
-//@ ### sed([options ,] search_regex, replacement, file)
-//@ Available options:
-//@
-//@ + `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js');
-//@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
-//@ ```
-//@
-//@ Reads an input string from `file` and performs a JavaScript `replace()` on the input
-//@ using the given search regex and replacement string or function. Returns the new string after replacement.
-function _sed(options, regex, replacement, file) {
- options = common.parseOptions(options, {
- 'i': 'inplace'
- });
-
- if (typeof replacement === 'string' || typeof replacement === 'function')
- replacement = replacement; // no-op
- else if (typeof replacement === 'number')
- replacement = replacement.toString(); // fallback
- else
- common.error('invalid replacement string');
-
- if (!file)
- common.error('no file given');
-
- if (!fs.existsSync(file))
- common.error('no such file or directory: ' + file);
-
- var result = fs.readFileSync(file, 'utf8').replace(regex, replacement);
- if (options.inplace)
- fs.writeFileSync(file, result, 'utf8');
-
- return common.ShellString(result);
-}
-module.exports = _sed;