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

bootme

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bootme - npm Package Compare versions

Comparing version 0.0.28 to 0.0.29

.nyc_output/0d6c4b61bd8f6160058525012d2fbe35.json

1

index.js

@@ -6,1 +6,2 @@ 'use strict'

module.exports.Pipeline = require('./lib/pipeline')
module.exports.State = require('./lib/state')

32

lib/pipeline.js

@@ -30,4 +30,4 @@ 'use strict'

this.errored = false
this.rollbacked = false
this.restored = false
this.rollbacking = false
this.restoring = false
this.error = null

@@ -55,3 +55,3 @@

*/
async get(name) {
get(name) {
if (Array.isArray(name)) {

@@ -93,3 +93,3 @@ let results = new Map()

async rollback() {
if (this.rollbacked) {
if (this.rollbacking) {
debug(`Rollback already in progress`)

@@ -99,5 +99,5 @@ return

this.rollbacked = true
this.rollbacking = true
for (let task of this.registry.tasks.filter(x => x.run).reverse()) {
for (let task of this.registry.tasks.filter(x => x.initialized).reverse()) {
// errors are swallowed so that each task can try to recover

@@ -124,3 +124,3 @@ try {

this.rollbacked = false
this.rollbacking = false
}

@@ -133,3 +133,3 @@ /**

async restore() {
if (this.restored) {
if (this.restoring) {
debug(`Restore already in progress`)

@@ -139,3 +139,3 @@ return

this.restored = true
this.restoring = true

@@ -161,3 +161,3 @@ for (let task of this.registry.tasks) {

this.restored = false
this.restoring = false
}

@@ -202,5 +202,7 @@ /**

task.addHook('onInit', async state => task.init(state))
task.addHook('onRollback', async state => task.rollback(state))
task.addHook('onInit', task.init)
task.addHook('onRollback', task.rollback)
// mark task as initialized so it can be filtered for rollback and restore
task.initialized = true
await task.executeHooks('onInit', state)

@@ -220,7 +222,5 @@ }

await this.initializeTask(task, state)
await task.executeHooks('onBefore', state)
// mark task as run so it can be filtered for rollback
task.run = true
await this.initializeTask(task, state)

@@ -272,3 +272,3 @@ const result = await task.action(state)

for (let task of this.registry.tasks) {
if (this.rollbacked) {
if (this.rollbacking) {
error('Abort Pipeline error %O', this.error)

@@ -275,0 +275,0 @@ break

@@ -76,2 +76,3 @@ 'use strict'

}
const t = this.tasks.find(t => t.name === task.name)

@@ -78,0 +79,0 @@

@@ -58,5 +58,16 @@ 'use strict'

this.pipeline.registry.addTask(task)
try {
this.pipeline.registry.addTask(task)
await this.pipeline.executeTask(task, state)
} catch (err) {
debug(
'Task <%s:%s> execute rollback routines due to (Task) error %O',
this.task.constructor.name,
this.task.name,
err
)
await this.pipeline.executeTask(task, state)
this.pipeline.error = err
await this.pipeline.rollback()
}
}

@@ -75,11 +86,2 @@ /**

this.queue.add(async child => {
if (this.pipeline.rollbacked) {
debug(
'Task <%s:%s> cancel next Job due to pipeline cancellation',
this.task.constructor.name,
this.task.name
)
return
}
try {

@@ -89,17 +91,10 @@ await fn(new State(child, this.task, this.pipeline))

debug(
'Task <%s:%s> execute rollback routines due to (Job) error',
'Task <%s:%s> execute rollback routines due to (Job) error %O',
this.task.constructor.name,
this.task.name
this.task.name,
err
)
// avoid error bubbling otherwise we rollback a second time
try {
await this.pipeline.rollback(err)
} catch (err) {
error(
'Task <%s:%s> error during (Job) rollback routine',
this.task.constructor.name,
this.task.name
)
}
this.pipeline.error = err
await this.pipeline.rollback()
}

@@ -106,0 +101,0 @@ })

@@ -35,3 +35,3 @@ 'use strict'

this.deps = []
this.run = false
this.initialized = false

@@ -146,6 +146,6 @@ return this

setInit(fn) {
if (typeof fn !== 'function') {
if (typeof fn !== 'function' && !(fn instanceof Task)) {
throw new TypeError(
`Task <${this.constructor.name}:${this
.name}> Init handler must be a function`
.name}> Init handler must be a function or Task instance`
)

@@ -165,6 +165,6 @@ }

setRollback(fn) {
if (typeof fn !== 'function') {
if (typeof fn !== 'function' && !(fn instanceof Task)) {
throw new TypeError(
`Task <${this.constructor.name}:${this
.name}> Rollback handler must be a function`
.name}> Rollback handler must be a function or Task instance`
)

@@ -188,3 +188,3 @@ }

`Task <${this.constructor.name}:${this
.name}> Hook handler of must be a function or Task instance`
.name}> Hook handler must be a function or Task instance`
)

@@ -191,0 +191,0 @@ }

{
"name": "bootme",
"version": "0.0.28",
"version": "0.0.29",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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