@@ -3,6 +3,7 @@ import * as del from 'del';
33import { config } from 'dotenv' ;
44import * as fsExtra from 'fs-extra' ;
55import * as path from 'path' ;
6+ import { Base } from '../src/lib/base' ;
67
78const npmRun = require ( 'npm-run' ) ;
89const assert = chai . assert ;
@@ -50,57 +51,39 @@ describe('Libs:run from console', () => {
5051 assert . equal ( fsExtra . existsSync ( indexTsFile ) , false ) ;
5152 } ) ;
5253 } ) ;
53- it ( 'tsc --pretty' , ( ) => {
54+ it ( 'tsc --pretty' , ( done : any ) => {
5455 const file = path . resolve ( `${ dirRoot } /dist/bin/app.js` ) ;
5556 const commandString = './node_modules/.bin/tsc --pretty' ;
56- const commandBin = commandString . split ( ' ' ) [ 0 ] ;
57- const commandArgs = commandString . split ( ' ' ) . filter ( ( arg : string , index : number ) => index > 0 ) ;
58- if ( debug ) {
59- console . log ( 'commandRunner#start' ) ;
60- console . log ( 'commandRunner#' , commandString ) ;
61- console . log ( 'commandRunner#' , file ) ;
62- }
63- const child = npmRun . spawnSync (
64- commandBin ,
65- commandArgs ,
66- { cwd : dirRoot }
67- ) ;
68- if ( debug ) {
69- console . log ( 'commandRunner#status' , child . status ) ;
70- console . log ( 'commandRunner#stderr' , child . stderr . toString ( ) ) ;
71- console . log ( 'commandRunner#stdout' , child . stdout . toString ( ) ) ;
72- console . log ( 'commandRunner#end' ) ;
73- }
74- assert . equal ( fsExtra . existsSync ( file ) , true ) ;
57+
58+ const base = new Base ( '' , dirRoot ) ;
59+ base . debug = debug ;
60+ base . commandRunner ( commandString ) . then ( ( data : boolean ) => {
61+ assert . equal ( fsExtra . existsSync ( file ) , true ) ;
62+ done ( ) ;
63+ } ) . catch ( function ( e ) {
64+ done ( e ) ;
65+ } ) ;
7566 } ) ;
76- it ( 'rucken prepare --lib --root ./test/fixture' , ( ) => {
67+ it ( 'rucken prepare --lib --root ./test/fixture' , ( done ) => {
7768 const file = path . resolve ( `${ dirRoot } /dist/bin/app.js` ) ;
78- const commandString = 'node ' + file + ' prepare --lib --root ./test/fixture' + ( debug ? ' --verbose' : '' ) ;
79- const commandBin = commandString . split ( ' ' ) [ 0 ] ;
80- const commandArgs = commandString . split ( ' ' ) . filter ( ( arg : string , index : number ) => index > 0 ) ;
81- if ( debug ) {
82- console . log ( 'commandRunner#start' ) ;
83- console . log ( 'commandRunner#' , commandString ) ;
84- }
69+ const commandString = 'node . prepare --lib --root ./test/fixture' + ( debug ? ' --verbose' : '' ) ;
70+
8571 assert . equal ( fsExtra . existsSync ( file ) , true ) ;
86- const child = npmRun . spawnSync (
87- commandBin ,
88- commandArgs ,
89- { cwd : dirRoot }
90- ) ;
91- if ( debug ) {
92- console . log ( 'commandRunner#status' , child . status ) ;
93- console . log ( 'commandRunner#stderr' , child . stderr . toString ( ) ) ;
94- console . log ( 'commandRunner#stdout' , child . stdout . toString ( ) ) ;
95- console . log ( 'commandRunner#end' ) ;
96- }
97- items . forEach ( ( {
98- dir : dir ,
99- translateTsFile : translateTsFile ,
100- indexTsFile : indexTsFile
101- } ) => {
102- assert . equal ( fsExtra . existsSync ( translateTsFile ) , true ) ;
103- assert . equal ( fsExtra . existsSync ( indexTsFile ) , true ) ;
72+
73+ const base = new Base ( '' , dirRoot ) ;
74+ base . debug = debug ;
75+ base . commandRunner ( commandString ) . then ( ( data : boolean ) => {
76+ items . forEach ( ( {
77+ dir : dir ,
78+ translateTsFile : translateTsFile ,
79+ indexTsFile : indexTsFile
80+ } ) => {
81+ assert . equal ( fsExtra . existsSync ( translateTsFile ) , true ) ;
82+ assert . equal ( fsExtra . existsSync ( indexTsFile ) , true ) ;
83+ } ) ;
84+ done ( ) ;
85+ } ) . catch ( function ( e ) {
86+ done ( e ) ;
10487 } ) ;
10588 } ) ;
10689 } ) ;
0 commit comments