11import { spawn } from 'child_process' ;
22import { env } from 'process' ;
3+
34import AdmZip from 'adm-zip' ;
45
6+ import { readJsonFromVisual } from './utils.js' ;
7+
8+ const ngJson = readJsonFromVisual ( 'angular.json' ) ;
9+
510export default class CommandManager {
611 public static start ( name : string , options : Record < string , string > , rootPath : string ) {
712 // Store the visual name in the node environment
@@ -30,6 +35,9 @@ export default class CommandManager {
3035 }
3136
3237 public static package ( name : string , options : Record < string , any > , rootPath : string ) {
38+ // Store the visual name in the node environment
39+ env . VISUAL_NAME = name ;
40+
3341 const ng = spawn ( 'ng' , [ 'build' , name ] ) ;
3442
3543 ng . stdout . on ( 'data' , data => {
@@ -42,9 +50,10 @@ export default class CommandManager {
4250
4351 ng . on ( 'close' , code => {
4452 if ( code == 0 ) {
53+ const outputPath = ngJson . projects [ name ] . architect . build . options . outputPath ;
4554 const zip = new AdmZip ( ) ;
46- zip . addLocalFolder ( rootPath + `/dist/ ${ name } ` ) ;
47- zip . writeZip ( rootPath + `/dist/ ${ name } .zip` , ( ) => {
55+ zip . addLocalFolder ( outputPath ) ;
56+ zip . writeZip ( outputPath + ' .zip' , ( ) => {
4857 console . log ( 'Package created.' ) ;
4958 } ) ;
5059 }
0 commit comments