fix command execution

This commit is contained in:
2017-04-02 14:48:23 +02:00
parent 77c6ef99c1
commit 822e480bdf
7 changed files with 56 additions and 33 deletions

View File

@ -19,6 +19,17 @@ export let run = () => {
}
})
npmdockerCli.addCommand('runinside').then(async (argvArg) => {
plugins.beautylog.ok('Allright. We are now in Docker!')
plugins.beautylog.log('now trying to run your specified command')
let configArg = await ConfigModule.run()
await plugins.smartshell.exec(configArg.command).then(response => {
if (response.exitCode !== 0) {
process.exit(1)
}
})
})
npmdockerCli.addCommand('clean').then(async (argvArg) => {
plugins.beautylog.ora.start()
plugins.beautylog.ora.text('cleaning up docker env...')

View File

@ -67,7 +67,11 @@ let buildDockerImage = async () => {
}
await plugins.smartshell.execSilent(
`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`
).then(async () => {
).then(async (response) => {
if (response.exitCode !== 0) {
console.log(response.stdout)
process.exit(1)
}
plugins.beautylog.ok('Dockerimage built!')
})
})
@ -119,7 +123,11 @@ let deleteDockerContainer = async () => {
* cleans up deletes the test image
*/
let deleteDockerImage = async () => {
await plugins.smartshell.exec(`docker rmi ${dockerData.imageTag}`)
await plugins.smartshell.execSilent(`docker rmi ${dockerData.imageTag}`).then(async (response) => {
if (response.exitCode !== 0) {
console.log(response.stdout)
}
})
}
/**
@ -162,4 +170,4 @@ export let run = async (configArg: IConfig): Promise<IConfig> => {
.then(postClean)
.catch(err => { console.log(err) })
return config
}
}

View File

@ -1,24 +1,17 @@
import * as plugins from "./npmdocker.plugins";
export interface IDockerfileSnippet {
baseImage:string;
command:string;
baseImage: string;
command: string;
}
export let dockerfileSnippet = (optionsArg:IDockerfileSnippet):string => {
let commandArray = optionsArg.command.split(/\s/);
let commandString:string = "";
for(let stringItem of commandArray){
if(!(commandString == "")){
commandString = commandString + ",";
}
commandString = commandString + '"' + stringItem + '"';
};
return plugins.smartstring.indent.normalize(`
export let dockerfileSnippet = (optionsArg: IDockerfileSnippet): string => {
return plugins.smartstring.indent.normalize(`
FROM ${optionsArg.baseImage}
RUN yarn global add npmdocker
COPY ./buildContextDir /workspace
WORKDIR /workspace
ENV CI=true
CMD [${commandString}];
`);
CMD ["npmdocker","runinside"];
`)
}