1- import * as fs from "fs-extra" ;
2- import * as path from "path" ;
1+ import {
2+ copy ,
3+ readFile ,
4+ mkdirs ,
5+ readdir ,
6+ unlinkSync ,
7+ remove ,
8+ writeFile ,
9+ } from "fs-extra" ;
10+ import { resolve , join } from "path" ;
311
412export interface DeployedPackage {
513 distPath : string ;
@@ -25,12 +33,9 @@ async function copyPackage(
2533) : Promise < void > {
2634 for ( const file of packageFiles ) {
2735 console . log (
28- `copying ${ path . resolve ( sourcePath , file ) } to ${ path . resolve (
29- destPath ,
30- file ,
31- ) } `,
36+ `copying ${ resolve ( sourcePath , file ) } to ${ resolve ( destPath , file ) } ` ,
3237 ) ;
33- await fs . copy ( path . resolve ( sourcePath , file ) , path . resolve ( destPath , file ) ) ;
38+ await copy ( resolve ( sourcePath , file ) , resolve ( destPath , file ) ) ;
3439 }
3540}
3641
@@ -39,13 +44,13 @@ export async function deployPackage(
3944) : Promise < DeployedPackage > {
4045 try {
4146 const packageJson : any = JSON . parse (
42- await fs . readFile ( packageJsonPath , "utf8" ) ,
47+ await readFile ( packageJsonPath , "utf8" ) ,
4348 ) ;
4449
4550 // Default to development build; use flag --release to indicate release build.
4651 const isDevBuild = ! process . argv . includes ( "--release" ) ;
47- const distDir = path . join ( __dirname , "../../../dist" ) ;
48- await fs . mkdirs ( distDir ) ;
52+ const distDir = join ( __dirname , "../../../dist" ) ;
53+ await mkdirs ( distDir ) ;
4954
5055 if ( isDevBuild ) {
5156 // NOTE: rootPackage.name had better not have any regex metacharacters
@@ -54,11 +59,11 @@ export async function deployPackage(
5459 ) ;
5560 // Dev package filenames are of the form
5661 // vscode-codeql-0.0.1-dev.2019.9.27.19.55.20.vsix
57- ( await fs . readdir ( distDir ) )
62+ ( await readdir ( distDir ) )
5863 . filter ( ( name ) => name . match ( oldDevBuildPattern ) )
5964 . map ( ( build ) => {
6065 console . log ( `Deleting old dev build ${ build } ...` ) ;
61- fs . unlinkSync ( path . join ( distDir , build ) ) ;
66+ unlinkSync ( join ( distDir , build ) ) ;
6267 } ) ;
6368 const now = new Date ( ) ;
6469 packageJson . version =
@@ -69,16 +74,16 @@ export async function deployPackage(
6974 `.${ now . getUTCHours ( ) } .${ now . getUTCMinutes ( ) } .${ now . getUTCSeconds ( ) } ` ;
7075 }
7176
72- const distPath = path . join ( distDir , packageJson . name ) ;
73- await fs . remove ( distPath ) ;
74- await fs . mkdirs ( distPath ) ;
77+ const distPath = join ( distDir , packageJson . name ) ;
78+ await remove ( distPath ) ;
79+ await mkdirs ( distPath ) ;
7580
76- await fs . writeFile (
77- path . join ( distPath , "package.json" ) ,
81+ await writeFile (
82+ join ( distPath , "package.json" ) ,
7883 JSON . stringify ( packageJson , null , 2 ) ,
7984 ) ;
8085
81- const sourcePath = path . join ( __dirname , ".." ) ;
86+ const sourcePath = join ( __dirname , ".." ) ;
8287 console . log (
8388 `Copying package '${ packageJson . name } ' and its dependencies to '${ distPath } '...` ,
8489 ) ;
0 commit comments