Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

task

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

task - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"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)))
// })
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc