@@ -9,7 +9,7 @@ const extend = require('util')._extend // eslint-disable-line
9
9
const win = process . platform === 'win32'
10
10
const logWithPrefix = require ( './util' ) . logWithPrefix
11
11
12
- //! after editing file dont forget run "npm test" and
12
+ //! after editing file don't forget run "npm test" and
13
13
//! change tests for this file if needed
14
14
15
15
// ? may be some addition info in silly and verbose levels
@@ -33,8 +33,8 @@ function colorizeOutput (color, string) {
33
33
}
34
34
35
35
//! on windows debug running with locale cmd (e. g. chcp 866) encoding
36
- // to avoid that uncoment next lines
37
- // locale encdoings couse issues. See run func for more info
36
+ // to avoid that uncomment next lines
37
+ // locale encodings cause issues. See run func for more info
38
38
// this lines only for testing
39
39
// win ? cp.execSync("chcp 65001") : null
40
40
// log.level = "silly";
@@ -46,7 +46,7 @@ class PythonFinder {
46
46
/**
47
47
*
48
48
* @param {string } configPython force setted from terminal or npm config python path
49
- * @param {(err:Error, found:string) => void } callback succsed /error callback from where result
49
+ * @param {(err:Error, found:string) => void } callback succeed /error callback from where result
50
50
* is available
51
51
*/
52
52
constructor ( configPython , callback ) {
@@ -109,7 +109,7 @@ class PythonFinder {
109
109
}
110
110
111
111
/**
112
- * Getting list of checks which should be cheked
112
+ * Getting list of checks which should be checked
113
113
*
114
114
* @private
115
115
* @returns {check[] }
@@ -256,7 +256,7 @@ class PythonFinder {
256
256
* @argument {check[]} checks
257
257
*/
258
258
async runChecks ( checks ) {
259
- // using this flag becouse Fail is happen when ALL checks fail
259
+ // using this flag because Fail is happen when ALL checks fail
260
260
let fail = true
261
261
262
262
for ( const check of checks ) {
@@ -319,7 +319,7 @@ class PythonFinder {
319
319
let args = this . argsExecutable
320
320
let shell = false
321
321
if ( this . win ) {
322
- // Arguments have to be manually quoted to avoid bugs with spaces in pathes
322
+ // Arguments have to be manually quoted to avoid bugs with spaces in paths
323
323
exec = `"${ exec } "`
324
324
args = args . map ( ( a ) => `"${ a } "` )
325
325
shell = true
@@ -354,8 +354,8 @@ class PythonFinder {
354
354
355
355
/**
356
356
*
357
- * Check if a getted path is correct and
358
- * Python executable hase the correct version to use.
357
+ * Check if a gotten path is correct and
358
+ * Python executable has the correct version to use.
359
359
*
360
360
* @private
361
361
* @argument {string} execPath path to check
@@ -370,7 +370,7 @@ class PythonFinder {
370
370
this . run ( execPath , this . argsVersion , false )
371
371
. then ( ( ver ) => {
372
372
// ? may be better code for version check
373
- // ? may be move log messgaes to catchError func
373
+ // ? may be move log messages to catchError func
374
374
const range = new semver . Range ( this . semverRange )
375
375
let valid = false
376
376
@@ -398,7 +398,7 @@ class PythonFinder {
398
398
colorizeOutput ( RED , 'THIS VERSION OF PYTHON IS NOT SUPPORTED' )
399
399
)
400
400
// object with error passed for conveniences
401
- // (becouse we may want to pass also stderr or some additional stuff )
401
+ // (because we may also want to pass stderr or other variables )
402
402
// eslint-disable-next-line prefer-promise-reject-errors
403
403
reject ( {
404
404
err : new Error ( `Found unsupported Python version ${ ver } ` )
@@ -443,27 +443,26 @@ class PythonFinder {
443
443
)
444
444
this . log . silly ( 'execFile: opts = ' , JSON . stringify ( opts , null , 2 ) )
445
445
446
- //* prosible outcomes with error messages on windows (err.message, error.stack?, stderr)
446
+ //* possible outcomes with error messages on Windows (err.message, error.stack?, stderr)
447
447
// issue of encoding (garbage in terminal ) when 866 or any other locale code
448
448
// page is setted
449
449
// possible solutions:
450
- // 1. let it be as it is and just warn user that it should use utf8
451
- // (already done in this.catchErros 's info statement)
452
- // 2. somehow determine user's terminal encdoing and use utils.TextDecoder
453
- // with getting raw buffer from execFile.
454
- // Requires to correct error.message becouse garbage persists there
455
- // 3. Forse user's terminal to use utf8 encoding via e.g. run "chcp 65001". May broke some user's programs
456
- // 4. use "cmd" command with flag "/U" and "/C" (for more informatiom run "help cmd")
450
+ // 1. leave it as is and just warn the user that it should use utf8
451
+ // (already done in this.catchError 's info statement)
452
+ // 2. somehow determine the user's terminal encoding and use utils.TextDecoder
453
+ // with the raw buffer from execFile.
454
+ // Requires to correct error.message because garbage persists there
455
+ // 3. Force the user's terminal to use utf8 encoding via e.g. run "chcp 65001". May break user's programs
456
+ // 4. use "cmd" command with flag "/U" and "/C" (for more information run "help cmd")
457
457
// which "Causes the output of
458
458
// internal commands ... to be Unicode" (utf16le)
459
459
//* note: find-python-script.py already send output in utf8 then may become necessary
460
460
//* to reencode string with Buffer.from(stderr).toString() or something
461
461
//* similar (if needed)
462
- // for this solution all execFile call should look like execFile("cmd /U /C", [command to run, arg1, arg2, ...])
463
- //* all pathes/commands and each argument must be in quotes becouse if they have
464
- //* spaces inside they will broke everything
462
+ // for this solution all execFile call should look like execFile("cmd", ["/U", "/C", command to run, arg1, arg2, ...])
463
+ //* all paths/commands and each argument must be in quotes if they contain spaces
465
464
466
- //* assume that user use utf8 compatible terminal
465
+ //* assume we have a utf8 compatible terminal
467
466
this . execFile ( exec , args , opts , execFileCallback . bind ( this ) )
468
467
469
468
/**
@@ -478,13 +477,13 @@ class PythonFinder {
478
477
( err && err . stack ) || err
479
478
)
480
479
481
- // executed script shouldn't pass anythong to stderr if successful
480
+ // executed script shouldn't pass anything to stderr if successful
482
481
if ( err || stderr ) {
483
482
reject ( { err : err || null , stderr : stderr || null } )
484
483
} else {
485
- // trim() function remove string endings that break string comparsion
486
- const stdoutTrimed = stdout . trim ( )
487
- resolve ( stdoutTrimed )
484
+ // trim() function removes string endings that would break string comparison
485
+ const stdoutTrimmed = stdout . trim ( )
486
+ resolve ( stdoutTrimmed )
488
487
}
489
488
}
490
489
} . bind ( this )
@@ -509,7 +508,7 @@ class PythonFinder {
509
508
// array of error codes (type of errors) that we handling
510
509
const catchedErrorsCods = [ 'ENOENT' , 9009 ]
511
510
512
- // dont know type of terminal errors
511
+ // don't know type of terminal errors
513
512
// @ts -ignore
514
513
if ( catchedErrorsCods . includes ( err ? err . code : undefined ) ) {
515
514
// @ts -ignore
@@ -596,7 +595,7 @@ class PythonFinder {
596
595
process . nextTick (
597
596
this . callback . bind (
598
597
null ,
599
- // if changing error message dont forget also change it test file too
598
+ // if changing error message don't forget also change it test file too
600
599
new Error ( 'Could not find any Python installation to use' )
601
600
)
602
601
)
@@ -606,7 +605,7 @@ class PythonFinder {
606
605
/**
607
606
*
608
607
* @param {string } configPython force setted from terminal or npm config python path
609
- * @param {(err:Error, found:string)=> void } callback succsed /error callback from where result
608
+ * @param {(err:Error, found:string)=> void } callback succeed /error callback from where result
610
609
* is available
611
610
*/
612
611
function findPython ( configPython , callback ) {
0 commit comments