File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ import * as path from 'path';
33import { exec , mkdtemp } from './util' ;
44import { compile } from './compile' ;
55import { Options } from './options' ;
6- import { ncp } from 'ncp' ;
6+ import { ncp as _ncp } from 'ncp' ;
7+ import { promisify } from 'util' ;
8+
9+ const ncp = promisify ( _ncp ) ;
710
811const pacmakModule = require . resolve ( 'jsii-pacmak/bin/jsii-pacmak' ) ;
912
@@ -38,11 +41,8 @@ export async function srcmak(srcdir: string, options: Options = { }) {
3841 if ( options . java ) {
3942 const source = path . resolve ( path . join ( workdir , 'dist/java/src/' ) ) ;
4043 const target = path . join ( options . java . outdir , 'src/' ) ;
41- ncp ( source , target , { clobber : false } , ( err ) => {
42- if ( err ) {
43- return console . error ( err ) ;
44- }
45- } ) ;
44+ await fs . mkdirp ( target ) ; // make sure target directory exists
45+ await ncp ( source , target , { clobber : false } ) ;
4646 }
4747 } ) ;
4848}
Original file line number Diff line number Diff line change @@ -62,7 +62,11 @@ test('fails if only one java option is given', () => {
6262} ) ;
6363
6464test ( 'python output' , async ( ) => {
65- await mkdtemp ( async outdir => {
65+ await mkdtemp ( async tmpdir => {
66+
67+ // put under a non-existent directory to verify it is created
68+ const outdir = path . join ( tmpdir , 'python' ) ;
69+
6670 srcmakcli ( srcdir ,
6771 '--entrypoint lib/main.ts' ,
6872 `--python-outdir ${ outdir } ` ,
@@ -76,7 +80,10 @@ test('python output', async () => {
7680} ) ;
7781
7882test ( 'java output' , async ( ) => {
79- await mkdtemp ( async outdir => {
83+ await mkdtemp ( async tmpdir => {
84+ // put under a non-existent directory to verify it is created
85+ const outdir = path . join ( tmpdir , 'java' ) ;
86+
8087 srcmakcli ( srcdir ,
8188 '--entrypoint lib/main.ts' ,
8289 `--java-outdir ${ outdir } ` ,
You can’t perform that action at this time.
0 commit comments