@nowa/module-script
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -6,2 +6,19 @@ # Change Log | ||
<a name="0.2.0"></a> | ||
# [0.2.0](https://github.com/nowa-webpack/nowa2/compare/@nowa/module-script@0.1.1...@nowa/module-script@0.2.0) (2018-02-06) | ||
### Bug Fixes | ||
* this bind when `parallel` is true ([0629d6e](https://github.com/nowa-webpack/nowa2/commit/0629d6e)) | ||
### Features | ||
* compatible for [@nowa](https://github.com/nowa)/core break change ([3e29281](https://github.com/nowa-webpack/nowa2/commit/3e29281)) | ||
* debug log module config ([c22278a](https://github.com/nowa-webpack/nowa2/commit/c22278a)) | ||
<a name="0.1.1"></a> | ||
@@ -8,0 +25,0 @@ ## 0.1.1 (2018-01-31) |
import { Module } from '@nowa/core'; | ||
export default class ModuleScript extends Module.Async<ModuleScript.Options> { | ||
export default class ModuleScript extends Module.Async<ModuleScript.Config> { | ||
$name: string; | ||
scripts: ModuleScript.IShellContent[]; | ||
scripts?: ModuleScript.SingleScript[]; | ||
options?: ModuleScript.IOptions; | ||
@@ -14,3 +14,3 @@ alreadyRun: boolean; | ||
export declare namespace ModuleScript { | ||
type IShellContent = string | (() => void | Promise<void>); | ||
type SingleScript = string | (() => void | Promise<void>); | ||
interface IOptions { | ||
@@ -21,6 +21,3 @@ parallel?: boolean; | ||
} | ||
type Options = IShellContent | IShellContent[] | { | ||
scripts: IShellContent[]; | ||
options?: IOptions; | ||
}; | ||
type Config = [SingleScript | SingleScript[], IOptions]; | ||
} |
22
index.js
@@ -10,3 +10,2 @@ "use strict"; | ||
this.$name = 'script'; | ||
this.scripts = []; | ||
this.alreadyRun = false; | ||
@@ -17,16 +16,7 @@ } | ||
const { logger } = this.$utils; | ||
const moduleOptions = this.$runtime.moduleOptions; | ||
if (Array.isArray(moduleOptions)) { | ||
logger.debug('arrayof string/function config received'); | ||
this.scripts.push(...moduleOptions.map(this.validateScript)); | ||
} | ||
else if (typeof moduleOptions === 'object') { | ||
logger.debug('{ scripts: [] } config received'); | ||
this.options = moduleOptions.options; | ||
this.scripts.push(...moduleOptions.scripts.map(this.validateScript)); | ||
} | ||
else { | ||
logger.debug('simple string/function config received'); | ||
this.scripts.push(this.validateScript(moduleOptions)); | ||
} | ||
const [scripts, options] = this.$runtime.config; | ||
this.options = options || {}; | ||
this.scripts = [].concat(scripts).map(this.validateScript); | ||
logger.info(`got ${this.scripts.length} scripts`); | ||
logger.debug(this.scripts); | ||
}); | ||
@@ -63,3 +53,3 @@ } | ||
logger.debug('parallel mode'); | ||
yield Promise.all(this.scripts.map(this._runScript)); | ||
yield Promise.all(this.scripts.map(this._runScript, this)); | ||
} | ||
@@ -66,0 +56,0 @@ else { |
{ | ||
"name": "@nowa/module-script", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "the nowa script module", | ||
@@ -27,7 +27,7 @@ "scripts": { | ||
"devDependencies": { | ||
"@nowa/core": "^0.4.1", | ||
"@nowa/core": "^0.5.0", | ||
"@types/execa": "^0.8.1" | ||
}, | ||
"peerDependencies": { | ||
"@nowa/core": "^0.4.0" | ||
"@nowa/core": "^0.5.0" | ||
}, | ||
@@ -34,0 +34,0 @@ "types": "./", |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
7264
5
1
72
104