User browserify to create a "packed" file.

@param {string} input - input file
@param {string} nc - node compiler dir
@param {array} options - nexe options
@param {function} complete - next function to call (async)
7542
function bundle(input, nc, options, complete) {
  const bundlePath = path.join(nc, 'lib', 'nexe.js');
  const mapfile = options.output + '.map';
  let ws = fs.createWriteStream(bundlePath);

  const igv = '__filename,__dirname,_process';
  let insertGlobalVars = { isNexe: true },
    wantedGlobalVars = igv.split(',');

  // parse insertGlobalVars.
  Object.keys(insertGlobals.vars).forEach(function(x) {
    if (wantedGlobalVars.indexOf(x) === -1) {
      insertGlobalVars[x] = undefined;
    }
  });

  let paths = [path.join(nc, 'lib')];

  if (options.browserifyPaths) {
    paths = paths.concat(options.browserifyPaths);
  }

  _log('executing browserify via API');
  let bproc = browserify([input], {
    debug: options.debug,
    commondir: false,
    paths: paths,
    builtins: false,
    insertGlobalVars: insertGlobalVars,
    detectGlobals: true,
    browserField: false,
  });

  if (options.browserifyExcludes && Array.isArray(options.browserifyExcludes)) {
    for (let i = 0; i < options.browserifyExcludes.length; i++) {
      let lib = options.browserifyExcludes[i];
      _log("Excluding '%s' from browserify bundle", lib);
      bproc.exclude(lib);
    }
  }

  // copy the excludes code for requires for now.
  if (options.browserifyRequires && Array.isArray(options.browserifyRequires)) {
    for (let i = 0; i < options.browserifyRequires.length; i++) {
      let lib = options.browserifyRequires[i];
      let name = lib.file || lib; // for  object format.
      // if `lib` is object then fetch all params without `file`
      // otherwise returns empty object
      let opts =
        (lib instanceof Object &&
          Object.keys(lib)
            .filter(key => key !== 'file')
            .reduce((acc, key) => {
              return (acc[key] = lib[key]), acc;
            }, {})) ||
        {};

      _log("Force including '%s' in browserify bundle", name);
      bproc.require(lib, opts);
    }
  }

  if (options.debug) {
    bproc.require(require.resolve('source-map-support'));
  }

  let bprocbun = bproc
    .bundle() // bundle
    .pipe(ws); // pipe to file

  // error on require errors, still can't contionue. ffs browserify
  bprocbun.on('error', function(err) {
    _log('error', '[browserify] ' + err);
  });

  ws.on('error', function(err) {
    console.log(err);
    _log('error', 'Failed to save stdout to disk');
    process.exit(1);
  });

  ws.on('close', function() {
    var source = fs.readFileSync(bundlePath, 'utf8');
    source = source.replace(/[^\x00-\x7F]/g, '');

    // write the source modified to nexe.js
    fs.writeFile(bundlePath, source, 'utf8', function(err) {
      if (err) {
        _log('error', 'failed to save source');
        process.exit(1);
      }

      complete();
    });
  });
}
1069604
function(content) {
				var output = new mCli.Output();
				this.commandOutputManager.onOutput({output: output});
				output.complete(content);
			}
1095121
function (userInput){
        var firstTimeRun = userInput.toLowerCase();
        if(firstTimeRun === 'yes'){
          createGulpFile({
            gulpFileSrcPath: '../templates/gulpfile.js',
            outputDir: '../../../gulpfile.js'
          }).exec({
            error: function (err){
              console.error('an error occurred- error details:',err);
              return exits.error();
            },
            invalid: function (){ exits.invalid() },
            success: function() {
              createGulpTasks({
                gulpFolderSrcPath: '../templates/tasks-gulp',
                outputFolderDir: '../../../tasks-gulp'
              }).exec({
                error: function (err){
                  console.error('an error occurred- error details:',err);
                  return exits.error();
                },
                invalid: function (){ exits.invalid() },
                success: function() {
                  createGulpEngine({
                    gulpFolderSrcPath: '../lib/gulp',
                    outputDir: '../../sails/lib/hooks/gulp'
                    //outputDir: '../../../api/hooks/gulp'
                  }).exec({
                    error: function (err){
                      console.error('an error occurred- error details:',err);
                      return exits.error();
                    },
                    invalid: function (){ exits.invalid() },
                    success: function() {
                      // return exits.success();
                      toggleSailsrc({
                        sailsrcSrc: '../json/gulp.sailsrc',
                        outputDir: '../../../.sailsrc'
                      }).exec({
                        error: function (err){
                          console.error('an error occurred- error details:',err);
                          return exits.error();
                        },
                        invalid: function (){ exits.invalid() },
                        success: function() {
                          // return exits.success();
                          installGulpDependencies({
                          }).exec({
                            error: function (err){
                              console.error('an error occurred- error details:',err);
                              return exits.error();
                            },
                            invalid: function (){ exits.invalid() },
                            success: function() {
                              return exits.success();
                            }
                          });
                        }
                      });
                    }
                  });
                }
              });
            }
          });
        }
        else if(firstTimeRun === 'no') {
          createGulpEngine({
            gulpFolderSrcPath: '../lib/gulp',
            outputDir: '../../sails/lib/hooks/gulp'
            //outputDir: '../../../api/hooks/gulp'
          }).exec({
            error: function (err){
              console.error('an error occurred- error details:',err);
              return exits.error();
            },
            invalid: function (){ exits.invalid() },
            success: function() {
              return exits.success();
            }
          });
        }
      }
170963
async function create(name, options, api, env) {
  // Grab the cwd and npmClient off of the environment. We can use these to
  // create the folder for the project and for determining what client to use
  // for npm-related commands
  const { CLI_ENV, cwd, npmClient } = env;
  // We support a couple of options for our `create` command, some only exist
  // during development (like link and linkCli).
  const { link, linkCli, plugins = [], presets = [], skip } = options;
  const root = path.join(cwd, name);

  logger.trace('Creating project:', name, 'at:', root);

  if (await fs.exists(root)) {
    throw new Error(`A folder already exists at \`${root}\``);
  }

  // Create the root directory for the new project
  await fs.ensureDir(root);

  const {
    writePackageJson,
    installDependencies,
    linkDependencies,
  } = await createClient(npmClient, root);
  const packageJson = {
    name,
    private: true,
    license: 'MIT',
    scripts: {},
    dependencies: {},
    devDependencies: {},
    toolkit: {},
  };

  // Write the packageJson to the newly created `root` folder
  await writePackageJson(packageJson);

  const installer = linkCli ? linkDependencies : installDependencies;
  await installer(['@carbon/toolkit']);

  if (CLI_ENV === 'production') {
    clearConsole();
  }

  if (skip) {
    displaySuccess(root, name, npmClient);
    return;
  }

  const toolkit = await which('toolkit', { cwd: root });

  if (presets.length > 0) {
    const args = ['add', ...presets, link && '--link'].filter(Boolean);
    await spawn(toolkit, args, {
      cwd: root,
      stdio: 'inherit',
    });
  }

  if (plugins.length > 0) {
    const args = ['add', ...plugins, link && '--link'].filter(Boolean);
    await spawn(toolkit, args, {
      cwd: root,
      stdio: 'inherit',
    });
  }

  displaySuccess(root, name, npmClient);
}
1156617
function napijs(options, resolve, reject) {
    if (_underscore2.default.isUndefined(options)) {
        return reject('Could not find options! Exiting...');
    }
    if (options.verbose) {
        _utils.logger.info('Starting with following options: ', options);
    }
    (0, _download2.default)(options).then(function (response) {
        var _iteratorNormalCompletion = true;
        var _didIteratorError = false;
        var _iteratorError = undefined;

        try {
            for (var _iterator = response[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
                var r = _step.value;

                if (!r.subtitlesPresent) {
                    _utils.logger.info('Could not download subtitles for file %s', r.file);
                }
            }
        } catch (err) {
            _didIteratorError = true;
            _iteratorError = err;
        } finally {
            try {
                if (!_iteratorNormalCompletion && _iterator.return) {
                    _iterator.return();
                }
            } finally {
                if (_didIteratorError) {
                    throw _iteratorError;
                }
            }
        }

        if (options.verbose) {
            _utils.logger.info('Done');
        }
        resolve(response);
    }).catch(function (err) {
        reject(err);
    });
}
698936
function(cfg, callback) {
  var lessCompiledCode = "";

  // Filter all Less files
  var lessFiles = filterInput(cfg.input_files, '.less');

  // Filter all Css files
  var cssFiles = filterInput(cfg.input_files, '.css');

  // Output file path
  var outputPath = path.join(cfg.output_dir, cfg.output_file);

  // Callback for Less compilation completed
  var onLessCompileComplete = function(result) {
    lessCompiledCode = result;
  };

  // Callback for style concatenation task
  var concatWithCssCompiledCode = function(result) {
    return result + '\n' + lessCompiledCode;
  };

  // Callback for lint task
  var onCSSLinted = function(blob) {
    if (blob.csslint && blob.csslint.length && blob.csslint[0].line !== undefined) {
      console.log('\nCSSLint reports issues in: '.red + blob.name);
      blob.csslint.forEach(function(i){
        if (i) {
          console.log(' Line ' + i.line + ', Col ' + i.col + ': ' + i.message);
        }
      });
    }
  };

  // Build Styles
  if (cssFiles.length+lessFiles.length > 0) {
    new gear.Queue({registry: taskRegistry}) // register tasks
    .log(formatLog('Building styles:', cssFiles.concat(lessFiles)))
    .tasks({
      readless:     {task: ['read', lessFiles]},
      combineless:  {requires: 'readless', task: 'safeconcat'},
      lesstocss:    {requires: 'combineless', task: ['lesscompile', {callback: onLessCompileComplete}]},
      readcss:      {requires: 'lesstocss', task: ['read', cssFiles]},
      lint:         {requires: 'readcss', task: cfg.lint ? ['csslint', {config: cfg.lint_config, callback: onCSSLinted}] : 'noop'},
      combinecss:   {requires: 'lint', task: 'safeconcat'},
      combineall:   {requires: 'combinecss', task: ['concat', {callback: concatWithCssCompiledCode}]},
      minify:       {requires: 'combineall', task: cfg.minify ? ['stylesminify', {minify: cfg.minify, yuicompress: cfg.minify_config.yuicompress}] : 'noop'},
      write:        {requires: 'minify', task: ['write', outputPath]}
    })
    .log(formatLog('Saved styles to: ', outputPath))
    .run(callback);
  } else {
    callback();
  }
}
770689
@GwtIncompatible("Unnecessary")
  private List<SourceFile> createSourceInputs(
      List<JsModuleSpec> jsModuleSpecs,
      List<FlagEntry<JsSourceType>> files,
      List<JsonFileSpec> jsonFiles,
      List<String> moduleRoots)
      throws IOException {
    if (isInTestMode()) {
      return inputsSupplierForTesting != null ? inputsSupplierForTesting.get()
          : null;
    }
    if (files.isEmpty() && jsonFiles == null) {
      // Request to read from stdin.
      files = ImmutableList.of(new FlagEntry<JsSourceType>(JsSourceType.JS, "-"));
    }

    for (JSError error : deduplicateIjsFiles(files, moduleRoots, !jsModuleSpecs.isEmpty())) {
      compiler.report(error);
    }

    try {
      if (jsonFiles != null) {
        return createInputs(files, jsonFiles, jsModuleSpecs);
      } else {
        return createInputs(files, true, jsModuleSpecs);
      }
    } catch (FlagUsageException e) {
      throw new FlagUsageException("Bad --js flag. " + e.getMessage());
    }
  }
1230885
function(src) {
    var _deferred = $q.defer();

    // Instance
    var _loadable = {

      src: src,

      // Loading completion flag
      isComplete: false,

      promise: _deferred.promise,

      // TODO switch to $document
      $element: document.createElement('script')
    };

    // Build DOM element
    _loadable.$element.src = src;
    _loadable.$element.type = 'text/javascript';
    _loadable.$element.async = false;

    _head.insertBefore(_loadable.$element, _head.firstChild);

    // Mark loading in progress
    _loadingList.push(_loadable);

    // Completion
    _loadable.$element.onload = _loadable.$element.onreadystatechange = function() {

      if(!_loadable.isComplete && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
        _loadable.isComplete = true;
        _loadable.$element.onload = _loadable.$element.onreadystatechange = null;
        
        if(_head && _loadable.$element.parentNode) {
          _head.removeChild(_loadable.$element);
        }

        // Mark complete
        var i = _loadingList.indexOf(_loadable);
        if(i !== -1) {
          _loadingList.splice(i, 1);
        }
        _completedList.push(_loadable);

        _deferred.resolve(_loadable);
      }
    };

    return _loadable;
  }
1119036
function init(options){

    return Promise.resolve()
      .then(function() {

        if(!_.get(parameters,'process.source')){
          return;
        }

        return Promise.resolve()
          .then(function() {
            return updateAllKeys(options);
          })
          .then(function() {
            return createMissingFolders(options);
          })
          .then(function() {
            return deleteUnused(options);
          })
          .then(function() {
            return deleteEmptyFolders(options);
          });

      })
      .then(function() {

        if(!_.get(parameters,'process.search')){
          return;
        }

        return require('./search')(util,options);

      })
      .then(function() {
        util.log('Sync is complete');
      });

  }
87190
function minify( file, options, done ){
		if (_.isFunction(options)){
			done = options;
			options = {};
		}
		if (!_.isObject(options))
			options = {};
		if (!_.isFunction(done))
			done = function(){};

		const canOptimize = options.optimize;
		delete options.optimize;

		console.log("  minify file %s...".grey, file);
		try {
			var code   = fs.readFileSync( file, {encoding: 'utf8'} );
			var minify = UglifyJS.minify( code, options );
		} catch (e) {
			return done(  new Error(`Error on parse file ${e.filename}`) );
		}

		if ( !minify || minify.error ) {
			if ( minify && minify.error )
				return done( new Error(minify.error.message) );
			return done(new Error('Minify error bundle.js') );
		}

		try{
			if ( canOptimize ){
				console.log("  optimize file %s...".grey, file );
				code = optimizeJs(minify.code);
			}else{
				code = minify.code;
			}
		}catch(e){
			console.error("Error on parse file %s", e.filename);
			return next(e);
		}

		fs.writeFile(
			file,
			code,
			function (err) {
				if ( err )
					return done(err);


				return done();
			}
		);
	}
1317561
function writeFileSync (fileName, data, options) {
    verifyFileName (fileName);
    
    var info = getFileInfo (fileName);
    if ((info.exists === true) && (info.isFile === false)) {
        var message1 = format (cc.MSG_IS_NOT_A_FILE, fileName);
        throw new SafeFileError (cc.IS_NOT_A_FILE, message1);
    }

    // if content undefined or null, set data to empty string
    if ((data === undefined) || (data === null)) {
        data = "";
    }

    // write file content, throwing exception on error occurring
    try {
        fs.writeFileSync (fileName, data, options);
    } catch (e) {
        var message2 = format (cc.MSG_WRITE_ERROR, e.message);
        throw new SafeFileError (cc.WRITE_ERROR, message2);
    }
}
1350467
function (inputNodes, options) {
  options = options || {}
  Plugin.call(this, inputNodes, {
    annotations: options.annotations
  })
  this.options = options
}
1054795
function(options, parentNode) {
	options = options || {};
	objects.mixin(this, options);

	this.options = options;
	this.checkOptions(this.options, ["serviceRegistry", "fileClient", "siteClient", "commandService", "statusService", "progressService"]); //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$

	this._fileClient = this.options.fileClient;
	this._siteClient = this.options.siteClient;
	this._commandService = this.options.commandService;
	this._statusService = this.options.statusService;
	this._progressService = this.options.progressService;

	this._commandsContainer = this.options.commandsContainer;

	if (this.options.location) {
		this.load(this.options.location);
	}

	this.node = parentNode || document.createElement("div"); //$NON-NLS-0$
}
45244
def files(input)
      (::Readline::FILENAME_COMPLETION_PROC.call(input) || []).map {|f|
        f =~ /^~/ ?  File.expand_path(f) : f
      }
    end
899916
function npmInstall(requires, done) {
    var npmBin = path.join(path.dirname(process.argv[0]), 'npm');
    if (process.platform === 'win32') { npmBin += '.cmd'; }
    async.forEachSeries(requires, function(module, next) {
      // skip existing modules
      if (grunt.file.exists(path.join('./node_modules/' + module))) {
        grunt.log.writeln(String('Module "' + module + '" already installed, skipping.').cyan);
        return next();
      }
      grunt.log.writeln('npm install ' + module + ' --save');
      // spawn npm install
      var s = grunt.util.spawn({
        cmd: npmBin,
        args: ['install', module, '--save']
      }, next);
      // write output
      s.stdout.on('data', function(buf) { grunt.log.write(String(buf)); });
      s.stderr.on('data', function(buf) { grunt.log.write(String(buf)); });
    }, done);
  }
219872
function (next) {

        async.each(input, function (path, done) {
            fs.stat(path, function (err, stats) {
                if (err) return done(err);
                if (stats.isDirectory())
                    return done("Cannot have a directory as input");
                done();
            });
        }, next);

    }
131427
function completeOpen() {
      if (process.stdout.isTTY) {
        rl = readline.createInterface(process.stdin, process.stdout);
        rl.setPrompt(chalk.dim('TinyG# '), 'TinyG# '.length);
        rl.prompt();

        // WARNING WARNING WARNING -- using the internals of node readline!!
        //
        // We need to override the default behavior for a few keys.
        // So, we tell stdin to REMOVE all of the listeners to the 'keypress'
        // event, then we will be the only listener. If we don't have a special
        // behavior for the pressed key, then we pass it on to the readline.
        //
        // To avoid using internals too much, we'll snarf in the listeners,
        // store them away, and then call them ourselves.
        var old_keypress_listeners = process.stdin.listeners('keypress');

        process.stdin.removeAllListeners('keypress');
        process.stdin.on('keypress', function (ch, k) {
          if (k && k.ctrl) {
            if (k.name == 'd') {
              if (sendingFile) {
                log(util.format(">>^d\n"));
                g.write('\x04'); // send the ^d
              }
              return;
            }
            else if (k.name == 'c') {
              var e = util.format("## Received CTRL-C in State '%s' -- sending CTRL-D and exiting.\n", STAT_CODES[latestMotionStatus]);
              log(e);
              if (interactive) {
                process.stdout.write(chalk.dim(e));
              }

              tryToQuit()
              return;
            }

          // Single character commands get sent immediately
        } else if (ch && ch.match(/^[!~%]/)) {
            log(util.format(">>%s\n", ch));
            g.write(ch);
            return;
          }

          for (var i = 0; i < old_keypress_listeners.length; i++) {
            old_keypress_listeners[i](ch,k);
          }
        })

        rl.on('line', function(line) {
          parseCommand(line);
          if (rl !== null) {
            rl.prompt(true);
          }
        });

        rl.on('close', function() {
          g.close();
          rl = null;
        });

        var leftText = "Progress |";
        var rightText = "|   0% ";

        var status = {};

        g.on('statusChanged', function(st) {
          for(var prop in st) {
            status[prop] = st[prop];
          }

          if (status.stat) {
            latestMotionStatus = status.stat;
          }

          if (interactive) {
            readline.moveCursor(process.stdout, 0, -1);
            readline.clearLine(process.stdout, 0);

            process.stdout.write(
              sprintf("\rPos: X=%4.2f Y=%4.2f Z=%4.2f A=%4.2f Vel:%4.2f",
                status.posx||0,
                status.posy||0,
                status.posz||0,
                status.posa||0,
                status.vel||0
              )
            );
            if (status.he1t) {
              process.stdout.write(
                sprintf(" He1=%4.2fºC/%4.2fºC",
                  status.he1t||0,
                  status.he1st||0
                )
              );
            }
            process.stdout.write(
              sprintf(" (%s)\n",
                STAT_CODES[status.stat] || 'Stopped'
              )
            );

            if (!sendingFile) {
              process.stdout.write(
                JSON.stringify(status, null, 0) + "\n"
              );

              rl.prompt(true);
            }
          }


          if (st.line && sendingFile) {
            if (st.line > maxLineNumber) {
              maxLineNumber = st.line;
            }
            // clear the whole line.
            // readline.moveCursor(process.stdout, 0, -1);
            // readline.clearLine(process.stdout, 0);
            process.stdout.write("\r");

            var maxWidth = process.stdout.columns;
            var paddingWidth = leftText.length + rightText.length;
            var barWidth = (maxWidth - paddingWidth) * (st.line/maxLineNumber);
            var barLeft = (maxWidth - paddingWidth);

            process.stdout.write(leftText);
            // console.error("maxWidth: %d, paddingWidth: %d, sent: %d, lines: %d", maxWidth, paddingWidth, b.sent, b.lines);
            while (barWidth > 1.0) {
              process.stdout.write('=');
              barWidth = barWidth - 1.0;
              barLeft--;
            }
            if (barWidth > 0.6) {
              process.stdout.write('+');
              barLeft--;
            } else if (barWidth > 0.3) {
              process.stdout.write('-');
              barLeft--;
            }
            while (barLeft-- > 0) {
              process.stdout.write('_');
            }

            process.stdout.write("| ")
            var percent = ((st.line/maxLineNumber) * 100);
            process.stdout.write(sprintf("%3.0f%%", percent));

            // if (process.stderr.isTTY) {
            //   process.stdout.write("\n")
            // } else {
              process.stdout.write("\r")
            // }
          } // if st.line
          // rl.prompt(true);
        }); // g.on('statusChanged', ... )
      }

      if (args.gcode || !process.stdin.isTTY) {
        sendFile(args.gcode || process.stdin, true);
      }
    }