@@ -7,10 +7,18 @@ import {
7
7
import { ng } from '../../utils/process' ;
8
8
import { updateJsonFile } from '../../utils/project' ;
9
9
import { oneLineTrim } from 'common-tags' ;
10
+ import * as fs from 'fs' ;
11
+ import * as path from 'path' ;
10
12
11
13
export default function ( ) {
12
14
return writeMultipleFiles ( {
13
15
'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\');' ,
14
22
'src/input-script.js' : 'console.log(\'input-script\');' ,
15
23
'src/lazy-script.js' : 'console.log(\'lazy-script\');' ,
16
24
'src/pre-rename-script.js' : 'console.log(\'pre-rename-script\');' ,
@@ -21,6 +29,12 @@ export default function () {
21
29
const app = configJson [ 'apps' ] [ 0 ] ;
22
30
app [ 'scripts' ] = [
23
31
'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' ,
24
38
{ input : 'input-script.js' } ,
25
39
{ input : 'lazy-script.js' , lazy : true } ,
26
40
{ input : 'pre-rename-script.js' , output : 'renamed-script' } ,
@@ -53,5 +67,24 @@ export default function () {
53
67
. 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 / ) )
54
68
. 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 / ) )
55
69
. 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
+ } ) ;
57
90
}
0 commit comments