Compare commits

..

No commits in common. '4163b7deb99885a043429eef0d5a05718b0e6df8' and '8997a762ed3ba5340d8c7fe1e72fff2c8069581b' have entirely different histories.

@ -12,7 +12,7 @@ const chalk = require("chalk");
let argv = yargs.argv;
let [ configurationPath, task, item ] = argv._;
let absoluteConfigurationPath = path.resolve(process.cwd(), configurationPath);
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
let configuration = require(absoluteConfigurationPath);
return Promise.try(() => {

@ -17,7 +17,7 @@ let configurationPath = argv._[0];
let listenHost = argv.listenHost ?? "127.0.0.1";
let listenPort = argv.listenPort ?? 3131;
let absoluteConfigurationPath = path.resolve(process.cwd(), configurationPath);
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
let configuration = require(absoluteConfigurationPath);
return Promise.try(() => {

@ -38,7 +38,7 @@ let configurationPath = argv._[0];
let listenHost = argv.listenHost ?? "127.0.0.1";
let listenPort = argv.listenPort ?? 3000;
let absoluteConfigurationPath = path.resolve(process.cwd(), configurationPath);
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
let configuration = require(absoluteConfigurationPath);
return Promise.try(() => {

@ -12,7 +12,7 @@ const chalk = require("chalk");
let argv = yargs.argv;
let [ configurationPath, task, item ] = argv._;
let absoluteConfigurationPath = path.resolve(process.cwd(), configurationPath);
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
let configuration = require(absoluteConfigurationPath);
return Promise.try(() => {

@ -159,13 +159,12 @@ module.exports = function (state) {
},
forItem: function (_options) {
// FIXME: Proper validation rules here for the other fields as well
let { item, task, mutationQueue, readTX, simulate, onDeleteSelf } = validateOptions(arguments, {
let { item, task, mutationQueue, readTX, simulate } = validateOptions(arguments, {
item: anything,
task: [ required, isTask ],
mutationQueue: anything,
readTX: maybeTX,
simulate: anything,
onDeleteSelf: isFunction
simulate: anything
});
// We create a new instance of the actual API for every item being processed. This is necessary because some of the input arguments will default to item-specific values, and some of the logic is dependent on task-specific metadata. This is a more efficient (and understandable) approach than pretending the API is stateless and then separately wrapping the API *again* for every individual item with a whole separate layer of input validation rules.
@ -262,11 +261,6 @@ module.exports = function (state) {
]
});
if (options.id === item.id) {
// This hook is necessary to allow the task kernel to skip certain operations in this case, eg. storing the task result - it would be redundant, and reference a now non-existent item.
onDeleteSelf();
}
return mutableOperation((tx) => {
return backend.deleteItem(tx, options);
});
@ -300,7 +294,6 @@ module.exports = function (state) {
updateData: function (_options) {
// NOTE: This is a semantically self-describing convenience wrapper for `storeItem` that updates the currently-being-processed item
// TODO: Have a dedicated alias and/or signature (for this function) for the common case of "just add a few attributes to whatever is already there"? ie. a shallow merge
let [ options ] = validateArguments(arguments, {
options: [ required, wrapValueAsOption("update"), {
id: [ defaultTo(item.id), isString ],

@ -8,14 +8,7 @@ const logStatus = require("./util/log-status");
module.exports = function ({ backend }) {
return function runTask(task, item) {
let queue = [];
let itemIsDeleted = false;
let api = backend.forItem({
task: task,
item: item,
mutationQueue: queue,
onDeleteSelf: () => { itemIsDeleted = true; }
});
let api = backend.forItem({ task: task, item: item, mutationQueue: queue });
return Promise.try(() => {
// TODO: Standardize logging control/levels interface, also for library use
@ -37,9 +30,7 @@ module.exports = function ({ backend }) {
});
});
}).then(async () => {
if (!itemIsDeleted) {
await api.internal.markTaskCompleted();
}
await api.internal.markTaskCompleted();
if (!process.env.SRAP_QUIET) {
logStatus(task, chalk.bold.green, "completed", item.id);

Loading…
Cancel
Save