22 * Copyright (c) Microsoft Corporation. All rights reserved.
33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
5- //@ts -check
6- const cp = require ( 'child_process' ) ;
7- const fs = require ( 'fs' ) ;
8- const path = require ( 'path' ) ;
5+
6+ import { spawn as _spawn } from 'child_process' ;
7+ import { readdirSync , readFileSync } from 'fs' ;
8+ import { join } from 'path' ;
9+ import url from 'url'
910
1011async function spawn ( cmd , args , opts ) {
1112 return new Promise ( ( c , e ) => {
12- const child = cp . spawn ( cmd , args , { shell : true , stdio : 'inherit' , env : process . env , ...opts } ) ;
13+ const child = _spawn ( cmd , args , { shell : true , stdio : 'inherit' , env : process . env , ...opts } ) ;
1314 child . on ( 'close' , code => code === 0 ? c ( ) : e ( `Returned ${ code } ` ) ) ;
1415 } ) ;
1516}
1617
1718async function main ( ) {
1819 await spawn ( 'yarn' , [ ] , { cwd : 'extensions' } ) ;
1920
20- for ( const extension of fs . readdirSync ( 'extensions' ) ) {
21+ for ( const extension of readdirSync ( 'extensions' ) ) {
2122 try {
22- let packageJSON = JSON . parse ( fs . readFileSync ( path . join ( 'extensions' , extension , 'package.json' ) ) . toString ( ) ) ;
23+ let packageJSON = JSON . parse ( readFileSync ( join ( 'extensions' , extension , 'package.json' ) ) . toString ( ) ) ;
2324 if ( ! ( packageJSON && packageJSON . scripts && packageJSON . scripts [ 'update-grammar' ] ) ) {
2425 continue ;
2526 }
@@ -33,13 +34,13 @@ async function main() {
3334 // run integration tests
3435
3536 if ( process . platform === 'win32' ) {
36- cp . spawn ( '.\\scripts\\test-integration.bat' , [ ] , { env : process . env , stdio : 'inherit' } ) ;
37+ _spawn ( '.\\scripts\\test-integration.bat' , [ ] , { env : process . env , stdio : 'inherit' } ) ;
3738 } else {
38- cp . spawn ( '/bin/bash' , [ './scripts/test-integration.sh' ] , { env : process . env , stdio : 'inherit' } ) ;
39+ _spawn ( '/bin/bash' , [ './scripts/test-integration.sh' ] , { env : process . env , stdio : 'inherit' } ) ;
3940 }
4041}
4142
42- if ( require . main === module ) {
43+ if ( import . meta . url === url . pathToFileURL ( process . argv [ 1 ] ) . href ) {
4344 main ( ) . catch ( err => {
4445 console . error ( err ) ;
4546 process . exit ( 1 ) ;
0 commit comments