@@ -8,21 +8,22 @@ const path = require('path')
88
99require ( 'npmlog' ) . level = 'warn'
1010
11- //* can use name as short descriptions
11+ //* name can be used as short descriptions
1212
1313/**
1414 * @typedef Check
15- * @property {string } path - path to execurtable or command
15+ * @property {string } path - path to executable or command
1616 * @property {string } name - very little description
1717 */
1818
19+ // TODO: add symlinks to python which will contain utf-8 chars
1920/**
2021 * @type {Check[] }
2122 */
2223const checks = [
2324 { path : process . env . PYTHON , name : 'env var PYTHON' } ,
24- { path : process . env . python2 , name : 'env var python2 ' } ,
25- { path : 'python3 ' , name : 'env var python3 ' }
25+ { path : 'python3' , name : 'python3 in PATH ' } ,
26+ { path : 'python ' , name : 'python in PATH ' }
2627]
2728const args = [ path . resolve ( './lib/find-python-script.py' ) ]
2829const options = {
@@ -32,37 +33,37 @@ const options = {
3233/**
3334 Getting output from find-python-script.py,
3435 compare it to path provided to terminal.
35- If equale - test pass
36+ If equals - test pass
3637
3738 runs for all checks
3839
3940 @private
4041 @argument {Error} err - exec error
4142 @argument {string} stdout - stdout buffer of child process
4243 @argument {string} stderr
43- @this {{t, exec: Check}}
44+ @this {{t: Tap , exec: Check}}
4445 */
4546function check ( err , stdout , stderr ) {
4647 const { t, exec } = this
4748 if ( ! err && ! stderr ) {
48- t . strictEqual (
49+ t . ok (
4950 stdout . trim ( ) ,
50- exec . path ,
5151 `${ exec . name } : check path ${ exec . path } equals ${ stdout . trim ( ) } `
5252 )
5353 } else {
5454 // @ts -ignore
55- if ( err . code === 9009 ) {
55+ if ( err . code === 9009 || err . code === 'ENOENT' ) {
5656 t . skip ( `skipped: ${ exec . name } file not found` )
5757 } else {
58- t . fail ( `error: ${ err } \n\nstderr: ${ stderr } ` )
58+ t . skip ( `error: ${ err } \n\nstderr: ${ stderr } ` )
5959 }
6060 }
6161}
6262
63- test ( 'find-python-script' , ( t ) => {
63+ test ( 'find-python-script' , { buffered : false } , ( t ) => {
6464 t . plan ( checks . length )
6565
66+ // ? may be more elegant way to pass context
6667 // context for check functions
6768 const ctx = {
6869 t : t ,
@@ -73,7 +74,7 @@ test('find-python-script', (t) => {
7374 // checking if env var exist
7475 if ( ! ( exec . path === undefined || exec . path === null ) ) {
7576 ctx . exec = exec
76- // passing ctx as coppied object to make properties immutable from here
77+ // passing ctx as copied object to make properties immutable from here
7778 const boundedCheck = check . bind ( Object . assign ( { } , ctx ) )
7879 execFile ( exec . path , args , options , boundedCheck )
7980 } else {
0 commit comments