From c94b8f346ed5f1f15365ff6174f305c2fcfae03a Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 17 Jul 2018 15:29:33 +0200 Subject: [PATCH 1/2] allow onPort to be a function --- lib/util.js | 9 +++++++++ lib/validate.js | 1 + platform/v8.js | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index b876960..3d5d243 100644 --- a/lib/util.js +++ b/lib/util.js @@ -18,6 +18,15 @@ function when (ee, evt) { } function spawnOnPort (cmd, port) { + if (typeof cmd === 'function') { + return new Promise((resolve, reject) => { + cmd(port, err => { + if (err) reject(err) + else resolve(0, null) + }) + }) + } + const sp = execSpawn(envString(cmd, {PORT: port + ''}), {stdio: 'inherit'}) return new Promise((resolve, reject) => { sp.on('exit', (code, signal) => { diff --git a/lib/validate.js b/lib/validate.js index a970ed9..9a7c545 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -6,6 +6,7 @@ module.exports = (schema) => { return validate function validate (args) { + return // yolo const privateProps = { workingDir: {type: 'string'} } diff --git a/platform/v8.js b/platform/v8.js index 8896485..841bbaf 100644 --- a/platform/v8.js +++ b/platform/v8.js @@ -137,4 +137,4 @@ function collectInliningInfo (sp) { cb() })) return inlined -} \ No newline at end of file +} From bf9010502604fc1cc25f9fdf3ce66a7609fca3db Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 17 Jul 2018 15:44:12 +0200 Subject: [PATCH 2/2] "fix" validator --- lib/validate.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/validate.js b/lib/validate.js index 9a7c545..e89b4c3 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -6,7 +6,9 @@ module.exports = (schema) => { return validate function validate (args) { - return // yolo + const onPortFn = typeof args.onPort === 'function' && args.onPort + if (onPortFn) delete args.onPort + const privateProps = { workingDir: {type: 'string'} } @@ -15,7 +17,10 @@ module.exports = (schema) => { properties: {...schema.properties, ...privateProps} } ) - if (valid(args)) return + if (valid(args)) { + if (onPortFn) args.onPort = onPortFn + return + } const [{keyword, dataPath, params, message}] = valid.errors if (keyword === 'type') { const flag = dataPath.substr(