New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fabula

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fabula - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

src/commands/ensure.js

2

package.json
{
"name": "fabula",
"version": "0.1.4",
"version": "0.1.5",
"description": "Minimalist server configuration and task management",

@@ -5,0 +5,0 @@ "author": "Jonas Galvez <jonasgalvez@gmail.com>",

@@ -5,3 +5,3 @@ <img src="https://user-images.githubusercontent.com/12291/50539530-e780e800-0b68-11e9-9453-e066015d0c2a.png">

<h1>Fabula
<a href="http://npmjs.com/package/fabula"><img src="https://badge.fury.io/js/fabula.svg?0.1.4"></a>
<a href="http://npmjs.com/package/fabula"><img src="https://badge.fury.io/js/fabula.svg?0.1.5"></a>
<a href="https://github.com/nuxt/fabula/actions"><img src="https://img.shields.io/badge/build-passing-47c11f.svg"></a></h1>

@@ -8,0 +8,0 @@ <span>Minimalist server configuration and task management.</span>

@@ -43,2 +43,12 @@

}
registerHandler(line) {
let match
// eslint-disable-next-line no-cond-assign
if (match = line.match(/^(.+?)(@[\w\d_]+)\s+$/)) {
this.handler = match[2]
return match[1]
} else {
return line
}
}
prepend(prepend, line) {

@@ -112,10 +122,35 @@ if (this.cmd.prepend) {

}
async run(conn, logger) {
async run(conn, logger, retry = null) {
let abort = this.settings.fail
const result = await this.cmd.command.call(this, conn, logger)
if (this.handler && this.settings[this.handler]) {
const fabula = {
abort: () => {
abort = true
}
}
await this.settings[this.handler](result, fabula)
}
if (result) {
// If failed and in a retry recursion, repeat until retry
if (result.code && retry) {
return this.run(conn, logger, retry - 1)
// Or, if failed for the first time, and settings.retry is set to
// a positive integer, start a new retry chain (recursion)
} else if (result.code && typeof this.settings.retry === 'number' && this.settings.retry) {
return this.run(conn, logger, this.settings.retry)
}
this.logLines(result.stdout, line => logger.info(this.context, line))
this.logLines(result.stderr, line => logger.info(this.context, line))
logger.info(this.context, result.code ? '[FAIL]' : '[OK]', this.argv.join(' '))
if (abort) {
logger.info(this.context, '[ABORT]', this.argv.join(' '))
return true
} else {
logger.info(this.context, result.code ? '[FAIL]' : '[OK]', this.argv.join(' '))
}
}
if (abort) {
return true
}
}
}
export default [
() => import('./fabula'),
() => import('./ensure'),
() => import('./get'),
() => import('./put'),

@@ -4,0 +7,0 @@ () => import('./write'),

@@ -42,4 +42,10 @@ import { readFileSync } from 'fs'

source = readFileSync(source).toString()
// Setup main settings
if (typeof config.fail === 'undefined') {
config.fail = true
}
const settings = { ...config }
// Create logger if not provided
if (logger == null) {

@@ -50,2 +56,4 @@ logger = createLogger(name, config)

let remoteServers = servers
// If no servers provided, run in local mode
if (servers.length === 0) {

@@ -56,2 +64,3 @@ await runLocalSource(name, source, settings, logger)

// Run in all servers
if (servers.length === 1 && servers[0] === 'all') {

@@ -62,6 +71,11 @@ remoteServers = Object.keys(config.ssh)

let conn
const runners = []
for (const server of remoteServers) {
conn = await getConnection(config.ssh[server])
await runSource(server, conn, name, source, settings, logger)
runners.push(() => new Promise(async (resolve) => {
conn = await getConnection(config.ssh[server])
await runSource(server, conn, name, source, settings, logger)
resolve()
}))
}
await Promise.all(runners.map(runner => runner()))
}
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