Sha256: a6d5767457f931bd34defd5fcf32e451f57cd5a4c0e9128b3ad1e0fcd2faaed1

Contents?: true

Size: 750 Bytes

Versions: 7

Compression:

Stored size: 750 Bytes

Contents

var common = require('./common');
var fs = require('fs');
var path = require('path');

//@
//@ ### 'string'.toEnd(file)
//@
//@ Examples:
//@
//@ ```javascript
//@ cat('input.txt').toEnd('output.txt');
//@ ```
//@
//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as
//@ those returned by `cat`, `grep`, etc).
function _toEnd(options, file) {
  if (!file)
    common.error('wrong arguments');

  if (!fs.existsSync( path.dirname(file) ))
      common.error('no such file or directory: ' + path.dirname(file));

  try {
    fs.appendFileSync(file, this.toString(), 'utf8');
  } catch(e) {
    common.error('could not append to file (code '+e.code+'): '+file, true);
  }
}
module.exports = _toEnd;

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/shelljs/src/toEnd.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/shelljs/src/toEnd.js
exercism-analysis-0.1.1 vendor/javascript/node_modules/jshint/node_modules/shelljs/src/toEnd.js
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/shelljs/src/toEnd.js
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/shelljs/src/toEnd.js
trans-0.5.10 template/node_modules/shelljs/src/toEnd.js
trans-0.5.9 template/node_modules/shelljs/src/toEnd.js