11const path = require ( 'path' ) ;
22const findCacheDir = require ( 'find-cache-dir' ) ;
3- const fsp = require ( '../lib/fs-promise' ) ;
43const defaultsDeep = require ( 'lodash.defaultsdeep' ) ;
5- const promiseTask = require ( '../lib/promise-task' ) ;
6- const Repository = require ( '../lib/repository' ) ;
7- const Loger = require ( '../lib/loger' ) ;
4+ const fsp = require ( './fs-promise' ) ;
5+ const queue = require ( './queue' ) ;
6+ const Repository = require ( './repository' ) ;
7+ const Loger = require ( './loger' ) ;
88const DEFAULT = require ( './config/config.default.json' ) ;
99const CACHE_DEFAULT = require ( './config/cache.default.json' ) ;
1010const PACKAGE = require ( '../package.json' ) ;
11-
12- const parse = require ( './parse' ) ;
13- const build = require ( './build' ) ;
11+ const createTasks = require ( './create-tasks' ) ;
12+ const runTasks = require ( './run-tasks' ) ;
1413
1514
1615/**
@@ -49,11 +48,11 @@ const taskRunner = (options = {}, context = process.cwd()) => {
4948
5049 const repository = new Repository ( options . cache , options . repository , 'revision' ) ;
5150
52- return promiseTask . serial ( [
51+ return queue . serial ( [
5352
5453
5554 // 将外部输入的配置转换成内部任务描述队列
56- parse ( options , context ) ,
55+ createTasks ( options , context ) ,
5756
5857
5958 // 检查任务是否有变更
@@ -67,8 +66,8 @@ const taskRunner = (options = {}, context = process.cwd()) => {
6766
6867 ] ) . then ( ( [ modCommit , ...libCommits ] ) => {
6968
70- let modChanged = modCommit [ 0 ] !== modCommit [ 1 ] ;
71- let libChanged = libCommits . filter ( libCommit => libCommit [ 0 ] !== libCommit [ 1 ] ) . length !== 0 ;
69+ const modChanged = modCommit [ 0 ] !== modCommit [ 1 ] ;
70+ const libChanged = libCommits . filter ( libCommit => libCommit [ 0 ] !== libCommit [ 1 ] ) . length !== 0 ;
7271 task . dirty = options . force || modChanged || libChanged ;
7372
7473 cache . tasks [ task . name ] = {
@@ -102,7 +101,7 @@ const taskRunner = (options = {}, context = process.cwd()) => {
102101
103102 // 运行构建器
104103 tasks => {
105- return build ( tasks , options . parallel ) ;
104+ return runTasks ( tasks , options . parallel ) ;
106105 } ,
107106
108107
@@ -113,7 +112,7 @@ const taskRunner = (options = {}, context = process.cwd()) => {
113112 . catch ( ( ) => defaultsDeep ( { } , CACHE_DEFAULT ) )
114113 . then ( oldAssets => defaultsDeep ( cache , oldAssets ) )
115114 . then ( cache => {
116- let json = JSON . stringify ( cache , null , 2 ) ;
115+ const json = JSON . stringify ( cache , null , 2 ) ;
117116 return fsp . writeFile ( options . cache , json , 'utf8' ) . then ( ( ) => cache ) ;
118117 } ) ;
119118 } ,
@@ -126,7 +125,7 @@ const taskRunner = (options = {}, context = process.cwd()) => {
126125 }
127126
128127 ] ) . then ( results => {
129- let timeEnd = Math . round ( ( Date . now ( ) - time ) / 1000 ) ;
128+ const timeEnd = Math . round ( ( Date . now ( ) - time ) / 1000 ) ;
130129 loger . log ( '░░' , `${ PACKAGE . name } :` , `${ timeEnd } s` ) ;
131130 return results [ results . length - 1 ] ;
132131 } ) ;
0 commit comments