@@ -7,10 +7,18 @@ import {
77import { ng } from '../../utils/process' ;
88import { updateJsonFile } from '../../utils/project' ;
99import { oneLineTrim } from 'common-tags' ;
10+ import * as fs from 'fs' ;
11+ import * as path from 'path' ;
1012
1113export default function ( ) {
1214 return writeMultipleFiles ( {
1315 'src/string-script.js' : 'console.log(\'string-script\'); var number = 1+1;' ,
16+ 'src/zstring-script.js' : 'console.log(\'zstring-script\');' ,
17+ 'src/fstring-script.js' : 'console.log(\'fstring-script\');' ,
18+ 'src/ustring-script.js' : 'console.log(\'ustring-script\');' ,
19+ 'src/bstring-script.js' : 'console.log(\'bstring-script\');' ,
20+ 'src/astring-script.js' : 'console.log(\'astring-script\');' ,
21+ 'src/cstring-script.js' : 'console.log(\'cstring-script\');' ,
1422 'src/input-script.js' : 'console.log(\'input-script\');' ,
1523 'src/lazy-script.js' : 'console.log(\'lazy-script\');' ,
1624 'src/pre-rename-script.js' : 'console.log(\'pre-rename-script\');' ,
@@ -21,6 +29,12 @@ export default function () {
2129 const app = configJson [ 'apps' ] [ 0 ] ;
2230 app [ 'scripts' ] = [
2331 'string-script.js' ,
32+ 'zstring-script.js' ,
33+ 'fstring-script.js' ,
34+ 'ustring-script.js' ,
35+ 'bstring-script.js' ,
36+ 'astring-script.js' ,
37+ 'cstring-script.js' ,
2438 { input : 'input-script.js' } ,
2539 { input : 'lazy-script.js' , lazy : true } ,
2640 { input : 'pre-rename-script.js' , output : 'renamed-script' } ,
@@ -53,5 +67,24 @@ export default function () {
5367 . then ( ( ) => expectFileMatchToExist ( 'dist' , / r e n a m e d - s c r i p t \. [ 0 - 9 a - f ] { 20 } \. b u n d l e \. j s / ) )
5468 . then ( ( ) => expectFileMatchToExist ( 'dist' , / r e n a m e d - s c r i p t \. [ 0 - 9 a - f ] { 20 } \. b u n d l e \. j s .m a p / ) )
5569 . then ( ( ) => expectFileToMatch ( 'dist/lazy-script.bundle.js' , 'lazy-script' ) )
56- . then ( ( ) => expectFileToMatch ( 'dist/renamed-lazy-script.bundle.js' , 'pre-rename-lazy-script' ) ) ;
70+ . then ( ( ) => expectFileToMatch ( 'dist/renamed-lazy-script.bundle.js' , 'pre-rename-lazy-script' ) )
71+
72+ // Expect order to be preserved.
73+ . then ( ( ) => {
74+ const [ fileName ] = fs . readdirSync ( 'dist' )
75+ . filter ( name => name . match ( / ^ s c r i p t s \. .* \. b u n d l e \. j s $ / ) ) ;
76+
77+ const content = fs . readFileSync ( path . join ( 'dist' , fileName ) , 'utf-8' ) ;
78+ const re = new RegExp ( / [ ' " ] s t r i n g - s c r i p t [ ' " ] .* / . source
79+ + / [ ' " ] z s t r i n g - s c r i p t [ ' " ] .* / . source
80+ + / [ ' " ] f s t r i n g - s c r i p t [ ' " ] .* / . source
81+ + / [ ' " ] u s t r i n g - s c r i p t [ ' " ] .* / . source
82+ + / [ ' " ] b s t r i n g - s c r i p t [ ' " ] .* / . source
83+ + / [ ' " ] a s t r i n g - s c r i p t [ ' " ] .* / . source
84+ + / [ ' " ] c s t r i n g - s c r i p t [ ' " ] .* / . source
85+ + / [ ' " ] i n p u t - s c r i p t [ ' " ] / . source ;
86+ if ( ! content . match ( re ) ) {
87+ throw new Error ( 'Scripts are not included in order.' ) ;
88+ }
89+ } ) ;
5790}
0 commit comments