11// Dependencies
2- import { constants , promises as fs } from 'fs' ;
3- import { getConfig } from ' vscode-get-config' ;
4- import { join } from ' path' ;
5- import { platform } from 'os' ;
6- import { spawn } from ' child_process' ;
7- import { window , type OutputChannel } from ' vscode' ;
8- import open from ' open' ;
2+ import { constants , promises as fs } from "fs" ;
3+ import { getConfig } from " vscode-get-config" ;
4+ import { join } from " path" ;
5+ import { platform } from "os" ;
6+ import { spawn } from " child_process" ;
7+ import { window , type OutputChannel } from " vscode" ;
8+ import open from " open" ;
99
1010async function clearOutput ( channel : OutputChannel ) : Promise < void > {
11- const { alwaysShowOutput } = await getConfig ( ' pynsist' ) ;
11+ const { alwaysShowOutput } = await getConfig ( " pynsist" ) ;
1212
1313 channel . clear ( ) ;
1414 if ( alwaysShowOutput === true ) {
1515 channel . show ( true ) ;
1616 }
1717}
1818
19- async function detectOutput ( relativePath : string , line : string , needle : DetectOutputOptions ) : Promise < string > {
19+ async function detectOutput (
20+ relativePath : string ,
21+ line : string ,
22+ needle : DetectOutputOptions ,
23+ ) : Promise < string > {
2024 if ( line . includes ( needle . string ) ) {
2125 const regex = needle . regex ;
2226 const result = regex . exec ( line . toString ( ) ) ;
2327 const absolutePath = join ( relativePath , result [ 1 ] ) ;
2428
25- return ( await fileExists ( absolutePath ) ) ? absolutePath : '' ;
29+ return ( await fileExists ( absolutePath ) ) ? absolutePath : "" ;
2630 }
2731
28- return '' ;
32+ return "" ;
2933}
3034
3135async function fileExists ( filePath : string ) : Promise < boolean > {
@@ -39,30 +43,32 @@ async function fileExists(filePath: string): Promise<boolean> {
3943}
4044
4145function getPrefix ( ) : string {
42- return platform ( ) === ' win32' ? '/' : '-' ;
46+ return platform ( ) === " win32" ? "/" : "-" ;
4347}
4448
4549async function getPath ( ) : Promise < string | number > {
46- const pathToPynsist = ( await getConfig ( ' pynsist.pathToPynsist' ) ) || ' pynsist' ;
50+ const pathToPynsist = ( await getConfig ( " pynsist.pathToPynsist" ) ) || " pynsist" ;
4751
4852 return new Promise ( ( resolve , reject ) => {
4953 if ( pathToPynsist ) {
50- console . log ( 'Using pynsist path found in user settings: ' + pathToPynsist ) ;
54+ console . log (
55+ "Using pynsist path found in user settings: " + pathToPynsist ,
56+ ) ;
5157 return resolve ( pathToPynsist ) ;
5258 }
5359
54- const which = spawn ( this . which ( ) , [ ' pynsist' ] ) ;
60+ const which = spawn ( this . which ( ) , [ " pynsist" ] ) ;
5561
56- which . stdout . on ( ' data' , ( data ) => {
57- console . log ( ' Using pynsist path detected on file system: ' + data ) ;
62+ which . stdout . on ( " data" , ( data ) => {
63+ console . log ( " Using pynsist path detected on file system: " + data ) ;
5864 return resolve ( data ) ;
5965 } ) ;
6066
61- which . on ( ' error' , ( errorMessage ) => {
67+ which . on ( " error" , ( errorMessage ) => {
6268 console . error ( { errorMessage : errorMessage } ) ;
6369 } ) ;
6470
65- which . on ( ' close' , ( code ) => {
71+ which . on ( " close" , ( code ) => {
6672 if ( code !== 0 ) {
6773 return reject ( code ) ;
6874 }
@@ -72,28 +78,32 @@ async function getPath(): Promise<string | number> {
7278
7379function pathWarning ( ) : void {
7480 window
75- . showWarningMessage ( 'pynsist is not installed or missing in your PATH environment variable' , 'Download' , 'Help' )
81+ . showWarningMessage (
82+ "pynsist is not installed or missing in your PATH environment variable" ,
83+ "Download" ,
84+ "Help" ,
85+ )
7686 . then ( ( choice ) => {
7787 switch ( choice ) {
78- case ' Download' :
79- open ( ' https://pypi.python.org/pypi/pynsist' ) ;
88+ case " Download" :
89+ open ( " https://pypi.python.org/pypi/pynsist" ) ;
8090 break ;
8191
82- case ' Help' :
83- open ( ' http://superuser.com/a/284351/195953' ) ;
92+ case " Help" :
93+ open ( " http://superuser.com/a/284351/195953" ) ;
8494 break ;
8595 }
8696 } ) ;
8797}
8898
8999async function runInstaller ( outFile : string ) : Promise < void > {
90- const { useWineToRun } = getConfig ( ' pynsist' ) ;
100+ const { useWineToRun } = getConfig ( " pynsist" ) ;
91101
92- if ( platform ( ) === ' win32' ) {
102+ if ( platform ( ) === " win32" ) {
93103 // Setting shell to true seems to prevent spawn UNKNOWN errors
94104 spawn ( outFile , [ ] , { shell : true } ) ;
95105 } else if ( useWineToRun === true ) {
96- spawn ( ' wine' , [ outFile ] ) ;
106+ spawn ( " wine" , [ outFile ] ) ;
97107 }
98108}
99109
@@ -102,7 +112,16 @@ function sanitize(response: unknown): string {
102112}
103113
104114function which ( ) : string {
105- return platform ( ) === ' win32' ? ' where' : ' which' ;
115+ return platform ( ) === " win32" ? " where" : " which" ;
106116}
107117
108- export { clearOutput , detectOutput , getPrefix , getPath , pathWarning , runInstaller , sanitize , which } ;
118+ export {
119+ clearOutput ,
120+ detectOutput ,
121+ getPrefix ,
122+ getPath ,
123+ pathWarning ,
124+ runInstaller ,
125+ sanitize ,
126+ which ,
127+ } ;
0 commit comments