1- var spawnSync = require ( 'child_process' ) . spawnSync
1+ import { spawnSync } from 'child_process'
22
33var styles = {
4- // got these from playing around with what I found from:
5- // https://github.com/istanbuljs/istanbuljs/blob/0f328fd0896417ccb2085f4b7888dd8e167ba3fa/packages/istanbul-lib-report/lib/file-writer.js#L84-L96
6- // they're the best I could find that works well for light or dark terminals
7- success : { open : '\u001b[32;1m' , close : '\u001b[0m' } ,
8- danger : { open : '\u001b[31;1m' , close : '\u001b[0m' } ,
9- info : { open : '\u001b[36;1m' , close : '\u001b[0m' } ,
10- subtitle : { open : '\u001b[2;1m' , close : '\u001b[0m' } ,
4+ // got these from playing around with what I found from:
5+ // https://github.com/istanbuljs/istanbuljs/blob/0f328fd0896417ccb2085f4b7888dd8e167ba3fa/packages/istanbul-lib-report/lib/file-writer.js#L84-L96
6+ // they're the best I could find that works well for light or dark terminals
7+ success : { open : '\u001b[32;1m' , close : '\u001b[0m' } ,
8+ danger : { open : '\u001b[31;1m' , close : '\u001b[0m' } ,
9+ info : { open : '\u001b[36;1m' , close : '\u001b[0m' } ,
10+ subtitle : { open : '\u001b[2;1m' , close : '\u001b[0m' } ,
1111}
1212
1313function color ( modifier , string ) {
14- return styles [ modifier ] . open + string + styles [ modifier ] . close
14+ return styles [ modifier ] . open + string + styles [ modifier ] . close
1515}
1616
1717console . log ( color ( 'info' , '▶️ Starting workshop setup...' ) )
1818
19- var output = spawnSync ( 'npm --version' , { shell : true } ) . stdout . toString ( ) . trim ( )
19+ var output = spawnSync ( 'npm --version' , { shell : true } )
20+ . stdout . toString ( )
21+ . trim ( )
2022var outputParts = output . split ( '.' )
2123var major = Number ( outputParts [ 0 ] )
2224var minor = Number ( outputParts [ 1 ] )
2325if ( major < 8 || ( major === 8 && minor < 16 ) ) {
24- console . error (
25- color (
26- 'danger' ,
27- '🚨 npm version is ' +
28- output +
29- ' which is out of date. Please install npm@8.16.0 or greater' ,
30- ) ,
31- )
32- throw new Error ( 'npm version is out of date' )
26+ console . error (
27+ color (
28+ 'danger' ,
29+ '🚨 npm version is ' +
30+ output +
31+ ' which is out of date. Please install npm@8.16.0 or greater' ,
32+ ) ,
33+ )
34+ throw new Error ( 'npm version is out of date' )
3335}
3436
3537var command =
36- 'npx "https://gist.github.com/kentcdodds/bb452ffe53a5caa3600197e1d8005733" -q'
38+ 'npx "https://gist.github.com/kentcdodds/bb452ffe53a5caa3600197e1d8005733" -q'
3739console . log (
38- color ( 'subtitle' , ' Running the following command: ' + command ) ,
40+ color ( 'subtitle' , ' Running the following command: ' + command ) ,
3941)
4042
41- var result = spawnSync ( command , { stdio : 'inherit' , shell : true } )
43+ var result = spawnSync ( command , { stdio : 'inherit' , shell : true } )
4244
4345if ( result . status === 0 ) {
44- console . log ( color ( 'success' , '✅ Workshop setup complete...' ) )
46+ console . log ( color ( 'success' , '✅ Workshop setup complete...' ) )
4547} else {
46- process . exit ( result . status )
48+ process . exit ( result . status )
4749}
4850
4951/*
5052eslint
5153 no-var: "off",
5254 "vars-on-top": "off",
53- */
55+ */
0 commit comments