コード例 #1
0
ファイル: index.js プロジェクト: codeactual/grunt-horde
GruntHorde.prototype.configuredDemand = function configuredDemand(source, context, section, key, val) {
  context = context || this;
  key = key.replace('initConfig.', '');

  if (source !== 'Gruntfile' && this.frozenConfig[key]) {
    this.grunt.event.emit('grunt-horde:demand', source, section, key, val, 'frozen');
    return context;
  }

  let mode = '';

  if (section === 'initConfig') {
    pathval.set(this.grunt.config.getRaw(), key, val);
  } else {
    if (this.config[section]) {
      pathval.set(this.config[section], key, val);
    } else {
      throw new Error(sprintf(
        'demand() key namespace "%s" does not exist, valid namespaces: %s',
        section, Object.keys(this.config).join(', ')
      ));
    }
  }

  if (source === 'Gruntfile') {
    this.frozenConfig[key] = true;
    mode = 'freezing';
  }

  this.grunt.event.emit('grunt-horde:demand', source, section, key, val, mode);
  return context;
};
コード例 #2
0
ファイル: index.js プロジェクト: codeactual/grunt-horde
  beforeEach(function() {
    // Clean up prior test's modifications to static config object.
    const gruntRawConfig = grunt.config.getRaw();
    Object.keys(gruntRawConfig).forEach(function(key) {
      delete gruntRawConfig[key];
    });

    this.horde = gruntHorde.create(grunt);

    this.origPathSep = path.sep;
    this.nonInitSection = 'registerTask';
    this.sectionKey = 'x.y.z';
    this.nonInitKey = this.nonInitSection + '.' + this.sectionKey;
    this.initKey = 'initConfig.' + this.sectionKey;
    this.val = 20;
    this.val2 = 21;
    this.initKeyValObj = {};
    pathval.set(this.initKeyValObj, this.sectionKey, this.val);
    this.config = {iAmA: 'fake config obj'};
    this.cwd = process.cwd();
    this.home = '/path/to/proj';
    this.modDirPath = '/path/to/nowhere';
    this.modInitFile = '/path/to/nowhere/initConfig/eslint.js';
    this.modNonInitFile = '/path/to/nowhere/' + this.nonInitSection + '.js';
    this.gruntStub = this.stub(grunt);
  });
コード例 #3
0
ファイル: translate.js プロジェクト: meen-girls/bb-gloss
 }, function(error, response, body) {
   if (body && body.data && body.data.translations) {
     var translation = body.data.translations[0].translatedText;
     pathval.set(translations, item.path, translation);
   }
   return nextPath(null);
 });
コード例 #4
0
ファイル: model.js プロジェクト: bodokaiser/node-exempel
Model.prototype.set = function(key, value) {
  if (lodash.isPlainObject(key)) {
    lodash.forIn(key, function(value, key) {
      this.set(key, value);
    }, this);
  }
  if (lodash.isString(key)) {
    pathval.set(this.attributes, key, value);

    this.emit('change:' + key, value);
    this.emit('change', key, value);
  }

  return this;
};
コード例 #5
0
ファイル: context.js プロジェクト: twolfson/reverse-mustache
  setToken: function (key, val, silent) {
    // Assert the token is not yet set
    // DEV: Even if they are the same, we are missing an optimization by reusing that knowledge
    if (!silent) {
      var currentVal = this.getToken(key);
      assert.strictEqual(currentVal, undefined, '`Context#setToken` expected `tokensByName["' + key + '"]` to not be defined but it was.');
    }

    // Set the value (including nested paths, `hello.world`)
    if (key === '.') {
      // We cannot use `pathval` for setting `.`
      this.tokensByName['.'] = val;
    } else {
      pathval.set(this.tokensByName, key, val);
    }
  },
コード例 #6
0
ファイル: projects.js プロジェクト: brendon-gonzalez/bb-gloss
 models.Locale.findOne(conditions, 'locale translations', function(error, locale) {
   if (!locale || error) {
     return res.send(500, 'unable to find locale for this project');
   }
   if (!pathval.get(locale.translations, body.key, body.value)) {
     return res.send(500, 'key does not exist for this locale');
   }
   pathval.set(locale.translations, body.key, body.value);
   locale.markModified('translations');
   locale.save(function(error, locale) {
     if (error) {
       return res.send(500, error);
     }
     return res.send(200);
   });
 });
コード例 #7
0
ファイル: index.js プロジェクト: qualiancy/gaia-schema
 this.paths.each(function(spec, path) {
   var datum = properties.get({ __root: data }, path);
   try { var unwrapped = self.unwrapPath(path, datum) }
   catch (e) { return errors.push(e); }
   properties.set(obj, path, unwrapped);
 });