describe('Has', () => { test('The key exists', () => { const condition = localTestData.conditions[0]; provider.register(condition); expect(provider.has(condition.name, condition.plugin)).toBeTruthy(); }); test(`The key doesn't exists`, () => { const { name, plugin } = localTestData.conditions[1]; expect(provider.has(name, plugin)).toBeFalsy(); }); });
const toUID = (name, plugin) => { const modelUID = Object.keys(strapi.contentTypes).find(key => { const ct = strapi.contentTypes[key]; if (ct.modelName === name && ct.plugin === plugin) return true; }); return modelUID; }
var onEmit = function (compiler, name, hook) { if (compiler.hooks) { // Webpack >= 4.0.0 compiler.hooks.emit.tapAsync(name, hook) } else { // Webpack < 4.0.0 compiler.plugin('emit', hook) } }
api.chainWebpack(config => { config.plugin('test-injections-3') .use(require('webpack/lib/DefinePlugin'), [{ 'TEST_3': JSON.stringify('test 3') }]) })
test("Taskr.constructor (exits)", t => { const fn = () => this.plugin("hello", {}, function * () {}) const plugins = { plugins: [fn] } const t1 = new Taskr({ plugins, tasks:['foo'] }) // test for `tasks_force_object` ? t1.on("tasks_force_object", () => console.log('HELLO?')) t.true(!t1.file && !t1.plugins, "exits EARLY if invalid `tasks` type") const t2 = new Taskr({ plugins }) t.true(t2.hasOwnProperty('file') && t2.hasOwnProperty('tasks'), "constructs shape") t.true($.isEmptyObj(t2.plugins), "stops before `plugins` loop if no `tasks` or `file`") t.end() })
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); });
modelAssociations .filter(association => { return association.plugin === 'upload'; }) .map(obj => obj.alias)
task.plugin("localPlugin", {every: 0}, function * (_, opts) { const t = opts.t t.true("root" in task && "emit" in task && "tasks" in task, "plugin creator receives `Taskr` instance") t.true("expand" in utils && "find" in utils && "write" in utils, "plugin creator receives `utils` helpers object") t.deepEqual(task, self, "plugin creator context bound to `task` instance") })
clientChain .plugin('injections') .tap(args => { const definitions = args[0] args[0] = { ...definitions, ...defines } return args })
/** * Return a SitePlugin instance used to handle the plugin * * @param {object} siteId - site ID * @param {string} pluginId - plugin identifier * @returns {any} SitePlugin instance */ const getPluginHandler = ( siteId, pluginId ) => { const siteHandler = wpcom.site( siteId ); return siteHandler.plugin( pluginId ); }
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); });
describe('Has', () => { test('The key exists', () => { const condition = localTestData.conditions[0]; provider.register(condition); expect(provider.has(condition.name, condition.plugin)).toBeTruthy(); }); test(`The key doesn't exists`, () => { const { name, plugin } = localTestData.conditions[1]; expect(provider.has(name, plugin)).toBeFalsy(); }); });
var onEmit = function (compiler, name, hook) { if (compiler.hooks) { // Webpack >= 4.0.0 compiler.hooks.emit.tapAsync(name, hook) } else { // Webpack < 4.0.0 compiler.plugin('emit', hook) } }
task.plugin("localPlugin", {every: 0}, function * (_, opts) { const t = opts.t t.true("root" in task && "emit" in task && "tasks" in task, "plugin creator receives `Taskr` instance") t.true("expand" in utils && "find" in utils && "write" in utils, "plugin creator receives `utils` helpers object") t.deepEqual(task, self, "plugin creator context bound to `task` instance") })