"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/coffee-script/lib/coffee-script/cake.js" (8 Mar 2017, 3017 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Generated by CoffeeScript 1.9.0
    2 (function() {
    3   var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
    4 
    5   fs = require('fs');
    6 
    7   path = require('path');
    8 
    9   helpers = require('./helpers');
   10 
   11   optparse = require('./optparse');
   12 
   13   CoffeeScript = require('./coffee-script');
   14 
   15   CoffeeScript.register();
   16 
   17   tasks = {};
   18 
   19   options = {};
   20 
   21   switches = [];
   22 
   23   oparse = null;
   24 
   25   helpers.extend(global, {
   26     task: function(name, description, action) {
   27       var _ref;
   28       if (!action) {
   29         _ref = [description, action], action = _ref[0], description = _ref[1];
   30       }
   31       return tasks[name] = {
   32         name: name,
   33         description: description,
   34         action: action
   35       };
   36     },
   37     option: function(letter, flag, description) {
   38       return switches.push([letter, flag, description]);
   39     },
   40     invoke: function(name) {
   41       if (!tasks[name]) {
   42         missingTask(name);
   43       }
   44       return tasks[name].action(options);
   45     }
   46   });
   47 
   48   exports.run = function() {
   49     var arg, args, e, _i, _len, _ref, _results;
   50     global.__originalDirname = fs.realpathSync('.');
   51     process.chdir(cakefileDirectory(__originalDirname));
   52     args = process.argv.slice(2);
   53     CoffeeScript.run(fs.readFileSync('Cakefile').toString(), {
   54       filename: 'Cakefile'
   55     });
   56     oparse = new optparse.OptionParser(switches);
   57     if (!args.length) {
   58       return printTasks();
   59     }
   60     try {
   61       options = oparse.parse(args);
   62     } catch (_error) {
   63       e = _error;
   64       return fatalError("" + e);
   65     }
   66     _ref = options["arguments"];
   67     _results = [];
   68     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
   69       arg = _ref[_i];
   70       _results.push(invoke(arg));
   71     }
   72     return _results;
   73   };
   74 
   75   printTasks = function() {
   76     var cakefilePath, desc, name, relative, spaces, task;
   77     relative = path.relative || path.resolve;
   78     cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile');
   79     console.log(cakefilePath + " defines the following tasks:\n");
   80     for (name in tasks) {
   81       task = tasks[name];
   82       spaces = 20 - name.length;
   83       spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
   84       desc = task.description ? "# " + task.description : '';
   85       console.log("cake " + name + spaces + " " + desc);
   86     }
   87     if (switches.length) {
   88       return console.log(oparse.help());
   89     }
   90   };
   91 
   92   fatalError = function(message) {
   93     console.error(message + '\n');
   94     console.log('To see a list of all tasks/options, run "cake"');
   95     return process.exit(1);
   96   };
   97 
   98   missingTask = function(task) {
   99     return fatalError("No such task: " + task);
  100   };
  101 
  102   cakefileDirectory = function(dir) {
  103     var parent;
  104     if (fs.existsSync(path.join(dir, 'Cakefile'))) {
  105       return dir;
  106     }
  107     parent = path.normalize(path.join(dir, '..'));
  108     if (parent !== dir) {
  109       return cakefileDirectory(parent);
  110     }
  111     throw new Error("Cakefile not found in " + (process.cwd()));
  112   };
  113 
  114 }).call(this);