Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} catch (err) {
service.logger.error('Post Start Init Service Error:', err);
return when.reject(err);
}
}
//
result = service.resources.postStartInit();
service._promiseQueue.push(result);
// wait for Q'd resources to resolve before letting service resolve
if (service._promiseQueue.length) {
service.logger.info('Wait Post Start Init...');
// TODO: need timeout in case resource promise never resolves
return when.all(service._promiseQueue).then(function () {
delete service._promiseQueue;
service.logger.info('Loaded');
service.logger.groupEnd(' ');
});
} else {
service.logger.groupEnd(' ');
return 1;
}
}.bind(this)).then(function (result) {
logger.groupEnd('Done Running All Post Start Inits');
var usedKeys = allSettings.models.map(function (setting) { return setting.get('key'); }),
insertOperations = [];
_.each(defaultSettings, function (defaultSetting, defaultSettingKey) {
var isMissingFromDB = usedKeys.indexOf(defaultSettingKey) === -1;
// Temporary code to deal with old databases with currentVersion settings
if (defaultSettingKey === 'databaseVersion' && usedKeys.indexOf('currentVersion') !== -1) {
isMissingFromDB = false;
}
if (isMissingFromDB) {
defaultSetting.value = defaultSetting.defaultValue;
insertOperations.push(Settings.forge(defaultSetting).save());
}
});
return when.all(insertOperations);
});
}
docClient.scan(scanningParameter, function (err, records) { // scanning database for getting all the records
if (!err) {
var recordsList = _.map(records.Items, function (record) { // for every record found
return when.promise(function (resolve, reject) {
recordExists(result.es, es_data, record).then(function (exists) { // check if record exists or not
return putRecord(result.es, es_data, record, exists)
}).then(function (record) {
resolve(record)
}, function (reason) {
reject(reason)
});
});
});
// return a promise array of all records
}
return when.all(recordsList);
})
}).done(function (records) {
it('provides "attach" for creating or attaching records', function(ok) {
var admin1 = new Admin({username: 'syncable', password: 'test'});
var admin2 = new Admin({username: 'syncable', password: 'test'});
when.all([admin1.save(), admin2.save()])
.then(function() {
return when.all([
new Site({id: 1}).admins().attach([admin1, admin2]),
new Site({id: 2}).admins().attach(admin2)
]);
})
.then(function(resp) {
return when.all([
new Site({id: 1}).admins().fetch().then(function(c) {
c.each(function(m) {
equal(m.hasChanged(), false);
});
equal(c.at(0).pivot.get('item'), 'test');
equal(c.length, 2);
}),
new Site({id: 2}).admins().fetch().then(function(c) {
var toggleAll = function (cores) {
if (!cores || (cores.length === 0)) {
console.log('No devices found.');
return when.resolve();
}
else {
var promises = [];
cores.forEach(function (core) {
if (!core.connected) {
promises.push(when.resolve(core));
return;
}
promises.push(api.signalCore(core.id, onOff));
});
return when.all(promises);
}
};
return fs.readdir(dir).then(function (files) {
return all(files.map(function (file) {
var path = pathify(dir, file);
return fs.stat(path).then(function (stats) {
return stats.isDirectory() ?
getPostPaths(path) :
path;
});
}));
}).then(function (files) {
return _.flatten(files);
var membership = this.getMemberships(message.roomId)
.then(memberships => _.find(memberships, {'personId': message.personId}))
.then(membership => {
trigger.personMembership = membership;
return when(true);
});
var files = this.parseFile(message)
.then(message => {
trigger.files = message.files || false;
return when(true);
});
return when.all([room, person, membership, files])
.then(() => when(trigger));
});
};
var args = util.format("%s %s -o %s %s", GRIB2JSON_FLAGS, recipe.filter, tempPath, productPath);
return tool.grib2json(args, process.stdout, process.stderr).then(function(returnCode) {
if (returnCode !== 0) {
log.info(util.format("grib2json failed (%s): %s", returnCode, productPath));
return when.reject(returnCode);
}
log.info("processing: " + tempPath);
var processed = processLayer(recipe, tempPath);
var layer = processed.layer, layerPath = layer.path(opt.layerHome);
mkdirp.sync(layer.dir(opt.layerHome));
fs.writeFileSync(layerPath, JSON.stringify(processed.data, null, INDENT), {encoding: "utf8"});
log.info("successfully built: " + layerPath);
return layer;
});
});
return when.all(layers);
}
router.use((transition) => {
return when.all(transition.routes.map((route) => {
if (route.RouteHandler.fetchData) {
return keys.all(route.RouteHandler.fetchData(transition.params, transition))
}
}))
})