File tree 3 files changed +18
-8
lines changed
3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { existsSync } from 'fs' ;
2
+ import { fileURLToPath } from 'url' ;
2
3
import execa from 'execa' ;
3
4
import { join } from 'path' ;
4
5
import { createTempDir , TempDir } from 'broccoli-test-helper' ;
5
6
import slash from 'slash' ;
6
7
7
- const COMPILED_BIN_PATH = new URL ( './bin.js' , import . meta. url ) . pathname ;
8
+ const COMPILED_BIN_PATH = fileURLToPath ( new URL ( './bin.js' , import . meta. url ) ) ;
9
+
8
10
if ( ! existsSync ( COMPILED_BIN_PATH ) ) {
9
- throw new Error ( 'Missing compiled output, run `yarn build`!' ) ;
11
+ throw new Error (
12
+ `Missing compiled output, run \`yarn build\`! Looked at ${ COMPILED_BIN_PATH } (based on ${
13
+ import . meta. url
14
+ } )`
15
+ ) ;
10
16
}
11
17
12
18
function run ( args : string [ ] , cwd : string ) {
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import * as os from 'os';
4
4
import { readFileSync } from 'fs' ;
5
5
import { program } from 'commander' ;
6
6
import run from './runner.js' ;
7
+ import { pathToFileURL } from 'url' ;
7
8
8
9
const version = JSON . parse (
9
10
readFileSync ( new URL ( '../package.json' , import . meta. url ) , { encoding : 'utf-8' } )
@@ -36,5 +37,6 @@ if (program.args.length < 1 || !programOptions.transform) {
36
37
silent : programOptions . silent ,
37
38
} ;
38
39
40
+ const transformPath = pathToFileURL ( programOptions . transform ) ;
39
41
run ( programOptions . transform , program . args , options ) ;
40
42
}
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import workerpool from 'workerpool';
12
12
13
13
tmp . setGracefulCleanup ( ) ;
14
14
15
- const WORKER_URL = new URL ( './worker.js' , import . meta. url ) ;
15
+ import { fileURLToPath } from 'url' ;
16
+ const WORKER_PATH = fileURLToPath ( new URL ( './worker.js' , import . meta. url ) ) ;
16
17
17
18
class NoFilesError extends Error { }
18
19
@@ -221,7 +222,7 @@ async function spawnWorkers(
221
222
222
223
logger . spin ( 'Processed 0 files' ) ;
223
224
224
- const pool = workerpool . pool ( WORKER_URL . pathname , { maxWorkers : cpus } ) ;
225
+ const pool = workerpool . pool ( WORKER_PATH , { maxWorkers : cpus } ) ;
225
226
226
227
let i = 0 ;
227
228
const worker = ( queue as any ) . async . asyncify ( async ( file : string ) => {
@@ -240,13 +241,14 @@ async function spawnWorkers(
240
241
241
242
function handleError ( err : any , logger : Logger ) : void {
242
243
if ( err . code === 'MODULE_NOT_FOUND' ) {
243
- logger . error ( ' Transform plugin not found' ) ;
244
+ logger . error ( ` Transform plugin not found` ) ;
244
245
} else if ( err instanceof NoFilesError ) {
245
246
logger . error ( 'No files matched' ) ;
246
247
} else {
247
248
logger . error ( err ) ;
248
- if ( err . stack ) {
249
- logger . error ( err . stack ) ;
250
- }
249
+ }
250
+
251
+ if ( err . stack ) {
252
+ logger . error ( err . stack ) ;
251
253
}
252
254
}
You can’t perform that action at this time.
0 commit comments