Example #1
0
/**
 * Takes an API name ("runtime", "cookies") and a root directory
 * that contains both common and chrome APIs, checking common first,
 * returning the entry if it exists from the appropriate `_api_features.json`.
 *
 * @param {string} name
 * @param {string} root
 * @return {object|null}
 */
function getManifestEntry (name, root) {
  var commonManifest = shush(join(root, "common", MANIFEST_FILE_NAME));
  if (commonManifest[name]) {
    return commonManifest[name];
  }
  var chromeManifest = shush(join(root, "chrome", MANIFEST_FILE_NAME));
  if (chromeManifest[name]) {
    return chromeManifest[name];
  }
  return null;
}
Example #2
0
 files.forEach(function (file) {
     var data;
     debug('loading config', file);
     data = shush(file);
     data = preprocessor.resolve(data);
     settings.use(file, data);
 });
        function fixDependencyVersion() {
            var projectDir = moduleOptions.projectDir;
            // var u = require('../lib/uniap/util');
            var packageFile = require('path').resolve(projectDir, 'package.json');
            // console.log('packageFile:', packageFile);
            if(!fs.existsSync(packageFile)) {
                // console.log('---NOT EXIST:', packageFile);
                return;
            }
            var config = shush(packageFile);
            if(!config) {
                return
            }

            addMissingDependency(config);

            fixNpmStart(config);

            if(config.dependencies) {
                config.dependencies = u.sortObject(config.dependencies);
                config.dependencies = u.fixDependencyVersion(config.dependencies);
            }
            if(config.devDependencies) {
                config.devDependencies = u.sortObject(config.devDependencies);
                config.devDependencies = u.fixDependencyVersion(config.devDependencies);
            }

            var cnt = JSON.stringify(config,null, 4);
            // console.log(cnt);

            fs.writeFileSync(packageFile,  cnt, {encoding: 'utf8'});

        }
Example #4
0
/**
 * Fetches the JSON definition for an API. Converts the webidl
 * formats if needed.
 *
 * @param {string} name
 * @param {string} root
 * @return {object?}
 */
function getDefinition (name, root) {
  var path = getDefinitionPath(name, root);
  if (!path) {
    return null;
  }
  if (/\.json$/.test(path)) {
    return shush(path)[0];
  }
  return webidlConvert(name, path)[0];
}
Example #5
0
 files.forEach(function (file) {
   var addViewArray = [shush(path.resolve(locatorDirectory, file))];
   var viewPathArray = file.split('/');
   viewPathArray[viewPathArray.length - 1] = viewPathArray[viewPathArray.length - 1].split('.json')[0];
   addViewArray.push(viewPathArray);
   try {
     nemo.view.addView.apply(this, addViewArray);
   } catch (err) {
     error(err);
     callback(err);
   }
 });
function transformGetBundle(n, projectDir) {
    if(! checkGetBundle(n) ) {
        return;
    }
    var args = n.arguments;
    var arg = args && args[0];
    var val = arg && arg.value;
    if(!val || !projectDir) {
        return;
    }



    var stats = fs.statSync(projectDir);
    if(!stats.isDirectory() ) {
        return;
    }


    var configFileDir = require('path').resolve(projectDir, './config');
    if(!fs.existsSync(configFileDir)) {
        u.exec('mkdir -p ' + configFileDir);
    }


    var configFileNameI18n = require('path').resolve(projectDir, './config/configi18n.json');
    if(!fs.existsSync(configFileNameI18n) ) {
        u.exec('touch ' + configFileNameI18n);
        fs.writeFileSync(configFileNameI18n,  '{ }', {encoding: 'utf8'});
    }

    var configFileName = require('path').resolve(projectDir, './config/config.json');



    if(!fs.existsSync(configFileName)) {
        console.log(' --- NO FILE: ', configFileName);
        return;
    }

    if(!fs.existsSync(configFileName) ) {
        u.exec('touch ' + configFileName);
    }

    var config = shush(configFileName);
    if(! config['i18n-ebay']) {
        config['i18n-ebay'] = {};
    }
    if( !config['i18n-ebay'].preload) {
        config['i18n-ebay'].preload = [];
    }
    var preloadArr = config['i18n-ebay'].preload;
    if(! _.contains(preloadArr, val) ) {
        preloadArr.push(val);

        // console.log(config['i18n-ebay']);
        // console.log(configFileName);
        if(config['i18n-ebay'].preload) {
            config['i18n-ebay'].preload = config['i18n-ebay'].preload.sort();
        }


        var cnt = JSON.stringify(config,null, 4);
        // console.log(cnt);

        fs.writeFileSync(configFileName,  cnt, {encoding: 'utf8'});
        fs.writeFileSync(configFileNameI18n,  cnt, {encoding: 'utf8'});

    }


}
Example #7
0
var getOptions = cli.getOptions = function (file) {
  var options = {},
      absFile = isAbsolute(file) ? file : path.resolve(process.cwd(), file),
      configKeys = [
        'pidFile', 'logFile', 'errFile', 'watch', 'minUptime', 'append',
        'silent', 'outFile', 'max', 'command', 'path', 'spinSleepTime',
        'sourceDir', 'workingDir', 'uid', 'watchDirectory', 'watchIgnore',
        'killTree', 'killSignal', 'id'
      ],
      specialKeys = ['script', 'args'],
      configs;

  //
  // Load JSON configuration values
  //
  if (path.extname(file) === '.json') {
    configs = shush(absFile);
    configs = !Array.isArray(configs) ? [configs] : configs;

    configs = configs.map(function (conf) {
      var mut = Object.keys(conf)
        .reduce(function (acc, key) {
          if (~configKeys.indexOf(key) || ~specialKeys.indexOf(key)) {
            acc[key] = conf[key];
          }

          return acc;
        }, {});

      if (!mut.script) {
        forever.log.error('"script" option required in JSON configuration files');
        console.log(prettyjson.render(mut));
        process.exit(1);
      }

      return mut;
    });
  } else {
    options.script = file;
  }

  //
  // First isolate options which should be passed to file
  //
  options.args = process.argv.splice(process.argv.indexOf(file) + 1);

  //
  // Now we have to force optimist to reparse command line options because
  // we've removed some before.
  //
  app.config.stores.argv.store = {};
  app.config.use('argv', argvOptions);

  configKeys.forEach(function (key) {
    options[key] = app.config.get(key);
  });

  options.watchIgnore         = options.watchIgnore || [];
  options.watchIgnorePatterns = Array.isArray(options.watchIgnore)
    ? options.watchIgnore
    : [options.watchIgnore];

  if (!options.minUptime) {
    forever.log.warn('--minUptime not set. Defaulting to: 1000ms');
    options.minUptime = 1000;
  }

  if (!options.spinSleepTime) {
    forever.log.warn([
      '--spinSleepTime not set. Your script',
      'will exit if it does not stay up for',
      'at least ' + options.minUptime + 'ms'
    ].join(' '));
  }

  function assignSpawnWith(options) {
    options.sourceDir  = options.sourceDir  || (file && file[0] !== '/' ? process.cwd() : '/');
    options.workingDir = options.workingDir || options.sourceDir;
    options.spawnWith  = { cwd: options.workingDir };
    return options;
  }

  if (configs && configs.length) {
    return configs.map(function (conf) {
      return assignSpawnWith(objectAssign(clone(options), conf));
    });
  }

  return [assignSpawnWith(options)];
};