Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "task", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "src/index.js", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -22,35 +22,46 @@ const { isAbsolute, dirname, join } = require('path') | ||
*/ | ||
const first = (entries, cwd, index = 0) => new Promise((resolve, reject) => { | ||
const entry = entries[index] | ||
if (!entry) return reject('no file found!') | ||
const file = getAbsolutePath(entry, cwd) | ||
fs.stat(file, err => resolve(err ? first(entries, cwd, index + 1) : file)) | ||
}) | ||
exports.types = { | ||
'build-js': (task, hub, cwd) => new Promise((resolve, reject) => { | ||
const opts = task.get('options', {}) | ||
const entry = opts.get(['entry', 'compute']) | ||
var entry = opts.get('entry', false).serialize() | ||
var dest = opts.get(['dest', 'compute']) | ||
if (!entry) return reject('no entry') | ||
if (dest) dest = getAbsolutePath(dest, cwd) | ||
if (!Array.isArray(entry)) entry = [ entry ] | ||
fs.realpath(getAbsolutePath(entry, cwd), (err, real) => { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
build(real, opts.serialize(), (err, result) => { | ||
if (!err) { | ||
if (dest) { | ||
task.set({ result }) | ||
Promise.all([ | ||
result.node && write(dest, result.node), | ||
result.inline && write(dest.replace(/.js$/, '.inline.js'), result.inline), | ||
result.browser && write(dest.replace(/.js$/, '.browser.js'), result.browser) | ||
]) | ||
.then(() => task.set({ done: true })) | ||
.catch(err => hub.emit('error', err)) | ||
} else { | ||
task.set({ | ||
result, | ||
done: true | ||
}) | ||
first(entry, cwd).then(entry => { | ||
if (dest) dest = getAbsolutePath(dest, cwd) | ||
fs.realpath(entry, (err, real) => { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
build(real, opts.serialize(), (err, result) => { | ||
if (!err) { | ||
if (dest) { | ||
task.set({ result }) | ||
Promise.all([ | ||
result.node && write(dest, result.node), | ||
result.inline && write(dest.replace(/.js$/, '.inline.js'), result.inline), | ||
result.browser && write(dest.replace(/.js$/, '.browser.js'), result.browser) | ||
]) | ||
.then(() => task.set({ done: true })) | ||
.catch(err => hub.emit('error', err)) | ||
} else { | ||
task.set({ | ||
result, | ||
done: true | ||
}) | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
}) | ||
}) | ||
@@ -57,0 +68,0 @@ |
@@ -7,3 +7,3 @@ const test = require('tape') | ||
test('simple js build (with cwd)', { timeout: 1000 }, t => { | ||
test('simple js build (with cwd)', { timeout: 2000 }, t => { | ||
ploy.set({ | ||
@@ -16,3 +16,3 @@ cwd: __dirname, | ||
options: { | ||
entry: 'files/a.js' | ||
entry: [ 'files/foo.js', 'files/a.js' ] | ||
} | ||
@@ -19,0 +19,0 @@ } |
@@ -1,42 +0,42 @@ | ||
const test = require('tape') | ||
const ploy = require('../../../') | ||
const fs = require('fs') | ||
const { join } = require('path') | ||
const deployServices = require('../') | ||
// const test = require('tape') | ||
// const ploy = require('../../../') | ||
// const fs = require('fs') | ||
// const { join } = require('path') | ||
// const deployServices = require('../') | ||
test.onFinish(() => process.exit()) | ||
// test.onFinish(() => process.exit()) | ||
test('deploy services', t => { | ||
ploy.set({ | ||
cwd: __dirname, | ||
tasks: { | ||
inject: [ deployServices ], | ||
deploy: { | ||
type: 'deploy-services', | ||
options: { | ||
package: fs.readFileSync(join(__dirname, 'package.json')).toString(), | ||
env: { | ||
RANDOM_ENV: 'boop' | ||
}, | ||
targets: { | ||
foo: { | ||
env: { | ||
RANDOM_ENV: 'bloop' | ||
} | ||
}, | ||
baz: { | ||
env: { | ||
FOO_ENV: 'baz' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
// test('deploy services', t => { | ||
// ploy.set({ | ||
// cwd: __dirname, | ||
// tasks: { | ||
// inject: [ deployServices ], | ||
// deploy: { | ||
// type: 'deploy-services', | ||
// options: { | ||
// package: fs.readFileSync(join(__dirname, 'package.json')).toString(), | ||
// env: { | ||
// RANDOM_ENV: 'boop' | ||
// }, | ||
// targets: { | ||
// foo: { | ||
// env: { | ||
// RANDOM_ENV: 'bloop' | ||
// } | ||
// }, | ||
// baz: { | ||
// env: { | ||
// FOO_ENV: 'baz' | ||
// } | ||
// } | ||
// } | ||
// } | ||
// } | ||
// } | ||
// }) | ||
t.plan(2) | ||
// t.plan(2) | ||
const deploy = ploy.get(['tasks', 'deploy'], {}) | ||
deploy.get('done').on(() => console.log(deploy.get('result').serialize(true))) | ||
}) | ||
// const deploy = ploy.get(['tasks', 'deploy'], {}) | ||
// deploy.get('done').on(() => console.log(deploy.get('result').serialize(true))) | ||
// }) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
150487
1422
22
9