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; };
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); });
}, 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); });
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; };
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); } },
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); }); });
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); });