Comparing version 0.1.6 to 0.1.7
{ | ||
"name": "fabula", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Minimalist server configuration and task management", | ||
@@ -19,6 +19,7 @@ "author": "Jonas Galvez <jonasgalvez@gmail.com>", | ||
"scripts": { | ||
"test": "jest", | ||
"test": "jest --detectOpenHandles --runInBand", | ||
"lint": "eslint --fix --ext .js,.vue src", | ||
"docs:dev": "vuepress dev docs", | ||
"docs:build": "source deploy.sh" | ||
"docs:build": "source deploy.sh", | ||
"postinstall": "yarn link && yarn link fabula" | ||
}, | ||
@@ -51,6 +52,4 @@ "dependencies": { | ||
"jest": "^23.6.0", | ||
"uptimer": "^0.1.2", | ||
"util": "^0.11.1", | ||
"vuepress": "^0.14.8" | ||
} | ||
} |
@@ -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.6"></a> | ||
<a href="http://npmjs.com/package/fabula"><img src="https://badge.fury.io/js/fabula.svg?0.1.7"></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> |
@@ -25,2 +25,6 @@ | ||
// const fabulaConfigHelper = () => { | ||
// } | ||
export async function loadConfig(rcFile = null) { | ||
@@ -27,0 +31,0 @@ let config |
@@ -35,2 +35,6 @@ | ||
this._env = env | ||
this.init(line) | ||
this.firstLine = true | ||
} | ||
init(line) { | ||
this.argv = parseArgv(line) | ||
@@ -42,3 +46,2 @@ this.local = this.argv[0] === 'local' | ||
this.source = [line] | ||
this.firstLine = true | ||
} | ||
@@ -48,4 +51,5 @@ registerHandler(line) { | ||
// eslint-disable-next-line no-cond-assign | ||
if (match = line.match(/^(.+?)(@[\w\d_]+)\s+$/)) { | ||
if (match = line.match(/^(.+?)@([\w\d_]+)\s*$/)) { | ||
this.handler = match[2] | ||
this.init(match[1]) | ||
return match[1] | ||
@@ -66,8 +70,3 @@ } else { | ||
line = `${prepend} ${line}` | ||
this.argv = parseArgv(line) | ||
this.local = this.argv[0] === 'local' | ||
if (this.local) { | ||
this.argv.shift() | ||
} | ||
this.source = [line] | ||
this.init(line) | ||
return line | ||
@@ -130,2 +129,3 @@ } | ||
const fabula = { | ||
vars: this.settings.vars, | ||
abort: () => { | ||
@@ -155,3 +155,3 @@ abort = true | ||
} | ||
if (abort || (result.code && this.settings.fail)) { | ||
if (abort || (result && result.code && this.settings.fail)) { | ||
return true | ||
@@ -158,0 +158,0 @@ } |
@@ -35,4 +35,13 @@ import { write, append } from '../ssh' | ||
const settingsKey = this.match[2] | ||
// eslint-disable-next-line no-eval | ||
this.params.fileContents = eval(`this.settings.${settingsKey}`).split(/\n/g) | ||
this.params.fileContents = () => { | ||
// If it's a variable, return raw value | ||
if (settingsKey.startsWith('vars.')) { | ||
// eslint-disable-next-line no-eval | ||
return eval(`this.settings.${settingsKey}`) | ||
// Treat everything else as a string | ||
} else { | ||
// eslint-disable-next-line no-eval | ||
return eval(`this.settings.${settingsKey}`).split(/\n/g) | ||
} | ||
} | ||
return false | ||
@@ -57,3 +66,5 @@ } else { | ||
const filePath = this.params.filePath | ||
const fileContents = this.params.fileContents.join('\n') | ||
const fileContents = typeof this.params.fileContents === 'function' | ||
? this.params.fileContents() | ||
: this.params.fileContents.join('\n') | ||
if (this.local) { | ||
@@ -60,0 +71,0 @@ const cmd = ({ write: localWrite, append: localAppend })[this.op] |
@@ -109,2 +109,3 @@ | ||
commandSearchList.push(execCommand) | ||
let _line | ||
for (cmd of commandSearchList) { | ||
@@ -114,5 +115,5 @@ if (cmd.match) { | ||
command.settings = settings | ||
let _line = line | ||
if (prepend && !/^\s+/.test(line)) { | ||
_line = command.prepend(prepend, line) | ||
_line = command.registerHandler(line) | ||
if (prepend && !/^\s+/.test(_line)) { | ||
_line = command.prepend(prepend, _line) | ||
} | ||
@@ -128,3 +129,3 @@ match = command.cmd.match.call(command, _line) | ||
} | ||
if (command.handleLine(line)) { | ||
if (command.handleLine(_line)) { | ||
push(command) | ||
@@ -141,5 +142,4 @@ return command | ||
const componentSettings = { | ||
...requireFromString(fabula.join('\n'), name).default | ||
} | ||
const _componentSettings = requireFromString(fabula.join('\n')) | ||
const componentSettings = _componentSettings.default || _componentSettings | ||
@@ -177,2 +177,13 @@ const globalEnv = { ...settings.env } | ||
const _vars = {} | ||
settings.vars = new Proxy(_vars, { | ||
get(obj, prop) { | ||
if (prop in obj) { | ||
return obj[prop] | ||
} else { | ||
return settings.strings[prop] | ||
} | ||
} | ||
}) | ||
// If no marked section is found, proceed to | ||
@@ -179,0 +190,0 @@ // regular commands compilation |
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
31606
17
1008
1
3