11import * as child_process from 'child_process' ;
22import chalk from 'chalk' ;
33import ora from 'ora' ;
4- import { bash , renameDockerImage } from '../script/utils' ;
4+ import {
5+ bash ,
6+ renameDockerImage ,
7+ isEmpty
8+ } from '../script/utils' ;
59import { CLIError } from '../script/cli' ;
610import logger from '../script/logger' ;
711import { initDefault } from '../config' ;
@@ -15,10 +19,14 @@ interface IArgs {
1519}
1620
1721
18- function buildDockerImage ( imageName : string , version : string , remoteAddress : string , publicUrl : string , dockerfile : string ) : Promise < string > {
22+ function buildDockerImage ( imageName : string , version : string , remoteAddress : string , dockerfile : string , publicUrl ? : string ) : Promise < string > {
1923
2024 return new Promise ( ( resolve , reject ) => {
21- const dockerBuildArgs = [ 'build' , '-t' , imageName , '-f' , dockerfile , '--build-arg' , `PUBLIC_URL=${ publicUrl } ` , '.' ] ;
25+ const options = {
26+ publicUrl : isEmpty ( publicUrl ) ? `PUBLIC_URL=${ publicUrl } ` : undefined ,
27+ } ;
28+ const dockerBuildArgs = [ 'build' , '-t' , imageName , '-f' , dockerfile , '--build-arg' , options . publicUrl , '.' ]
29+ . filter ( arg => typeof arg !== 'undefined' ) as string [ ] ;
2230
2331 const loader = ora ( ) ;
2432 logger . info (
@@ -87,7 +95,7 @@ async function run(args?: IArgs) {
8795 console . log ( `ready release ${ imageName } :${ imageVersion } ...` ) ;
8896
8997 // Build Image
90- const targetImageName = await buildDockerImage ( imageName , imageVersion , remoteAddress , publicUrl , dockerfile ) ;
98+ const targetImageName = await buildDockerImage ( imageName , imageVersion , remoteAddress , dockerfile , publicUrl ) ;
9199
92100 // By OSX Notice
93101 bash ( `osascript -e 'display notification "${ targetImageName } done" with title "build done"'` ) ;
0 commit comments