Sha256: d5fb825a744d8d4320678360f89df51f6c6bc12cf0d99120081907003186467d

Contents?: true

Size: 1.29 KB

Versions: 49

Compression:

Stored size: 1.29 KB

Contents

require('./global');

global.config.fatal = true;
global.target = {};

var args = process.argv.slice(2),
  targetArgs,
  dashesLoc = args.indexOf('--');

// split args, everything after -- if only for targets
if (dashesLoc > -1) {
  targetArgs = args.slice(dashesLoc + 1, args.length);
  args = args.slice(0, dashesLoc);
}

// This ensures we only execute the script targets after the entire script has
// been evaluated
setTimeout(function() {
  var t;

  if (args.length === 1 && args[0] === '--help') {
    console.log('Available targets:');
    for (t in global.target)
      console.log('  ' + t);
    return;
  }

  // Wrap targets to prevent duplicate execution
  for (t in global.target) {
    (function(t, oldTarget){

      // Wrap it
      global.target[t] = function() {
        if (!oldTarget.done){
          oldTarget.done = true;
          oldTarget.result = oldTarget.apply(oldTarget, arguments);
        }
        return oldTarget.result;
      };

    })(t, global.target[t]);
  }

  // Execute desired targets
  if (args.length > 0) {
    args.forEach(function(arg) {
      if (arg in global.target)
        global.target[arg](targetArgs);
      else {
        console.log('no such target: ' + arg);
      }
    });
  } else if ('all' in global.target) {
    global.target.all(targetArgs);
  }

}, 0);

Version data entries

49 entries across 49 versions & 5 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/shelljs/make.js
govuk_publishing_components-17.21.0 node_modules/shelljs/make.js
govuk_publishing_components-17.20.0 node_modules/shelljs/make.js
govuk_publishing_components-17.19.1 node_modules/shelljs/make.js
govuk_publishing_components-17.19.0 node_modules/shelljs/make.js
govuk_publishing_components-17.18.0 node_modules/shelljs/make.js
govuk_publishing_components-17.17.0 node_modules/shelljs/make.js
govuk_publishing_components-17.16.0 node_modules/shelljs/make.js
govuk_publishing_components-17.15.0 node_modules/shelljs/make.js
govuk_publishing_components-17.14.0 node_modules/shelljs/make.js
govuk_publishing_components-17.13.0 node_modules/shelljs/make.js
govuk_publishing_components-17.12.2 node_modules/shelljs/make.js
govuk_publishing_components-17.12.1 node_modules/shelljs/make.js
govuk_publishing_components-17.12.0 node_modules/shelljs/make.js
govuk_publishing_components-17.11.0 node_modules/shelljs/make.js
govuk_publishing_components-17.10.0 node_modules/shelljs/make.js
govuk_publishing_components-17.9.0 node_modules/shelljs/make.js
govuk_publishing_components-17.8.0 node_modules/shelljs/make.js
govuk_publishing_components-17.7.0 node_modules/shelljs/make.js
govuk_publishing_components-17.6.1 node_modules/shelljs/make.js