/* * Wipe the ENTIRE data source */ delete(source, id) { if (!id) throw Error('Specify a resource ID to remove!'); const database = _(this.read(source)).filter(item => item.id !== id).value(); this.yaml.dump(path.resolve(this.base, `${source}.yml`), database); return id; }
base() { return { items: componentForm.base(), }; }
this.base(table.name) .select(table.select || {}) .eachPage((records, fetchNextPage) => { records.forEach((record) => { this.addRecordToNode(record._rawJson, table, collection) }) fetchNextPage() })
task.plugin('uglify', {}, function * (file, opts) { opts = Object.assign({}, opts, { fromString:true }); const ext = extname(file.base); const rgx = new RegExp(`\\${ext}$`, 'i'); // replace extension with `.js` file.base = file.base.replace(rgx, '.js'); const out = minify(file.data.toString(), opts); // write output file.data = new Buffer(out.code); });
/** * Alternative to Node's `path.basename`, removing query string after the extension if it exists. * @param {string} path Path to get the basename of * @param {string} [ext] File extension to remove * @returns {string} Basename of the path * @private */ static basename(path, ext) { let res = parse(path); return ext && res.ext.startsWith(ext) ? res.name : res.base.split('?')[0]; }
submit() { this.value = {}; for (let choice of this.choices) { this.value[choice.name] = choice.scaleIndex; } return this.base.submit.call(this); }
/* * Create a data source */ create(source, data = {}, sort = []) { let database = this.read(source); database.push(_.merge({}, data, {id: hasher(data)})); // Sort if we have to if (!_.isEmpty(sort)) database = _.orderBy(database, ...sort); // Dump results this.yaml.dump(path.resolve(this.base, `${source}.yml`), _.uniqBy(database, 'id')); return this.read(source, {id: hasher(data)}); }
submit() { this.value = {}; for (let choice of this.choices) { this.value[choice.name] = choice.scaleIdx; } return this.base.submit.call(this); }
base() { return { items: componentForm.base(), }; }
task.plugin('uglify', {}, function * (file, opts) { opts = Object.assign({}, opts, { fromString:true }); const ext = extname(file.base); const rgx = new RegExp(`\\${ext}$`, 'i'); // replace extension with `.js` file.base = file.base.replace(rgx, '.js'); const out = minify(file.data.toString(), opts); // write output file.data = new Buffer(out.code); });
function init() { const Plugin = { enable(walk) { walk.base.Import = noop return walk } } return Plugin }
this.base(table.name) .select(table.select || {}) .eachPage((records, fetchNextPage) => { records.forEach((record) => { this.addRecordToNode(record._rawJson, table, collection) }) fetchNextPage() })