fix command execution

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

View File

@ -1,5 +1,6 @@
FROM hosttoday/ht-docker-node:npmci
RUN yarn global add npmdocker
COPY ./buildContextDir /workspace
WORKDIR /workspace
ENV CI=true
CMD ["npmci","test","stable"];
CMD ["npmdocker","runinside"];

12
dist/npmdocker.cli.js vendored
View File

@ -25,6 +25,16 @@ exports.run = () => {
process.exit(1);
}
}));
npmdockerCli.addCommand('runinside').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.ok('Allright. We are now in Docker!');
plugins.beautylog.log('now trying to run your specified command');
let configArg = yield ConfigModule.run();
yield plugins.smartshell.exec(configArg.command).then(response => {
if (response.exitCode !== 0) {
process.exit(1);
}
});
}));
npmdockerCli.addCommand('clean').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.ora.start();
plugins.beautylog.ora.text('cleaning up docker env...');
@ -48,4 +58,4 @@ exports.run = () => {
}));
npmdockerCli.startParse();
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUE4QztBQUc5QyxVQUFVO0FBQ1YsbURBQWtEO0FBQ2xELG1EQUFrRDtBQUVsRCxJQUFJLFlBQVksR0FBRyxJQUFJLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUE7QUFFdkMsUUFBQSxHQUFHLEdBQUc7SUFDZixZQUFZLENBQUMsWUFBWSxFQUFFLENBQUMsSUFBSSxDQUFDLENBQU8sT0FBTztRQUM3QyxJQUFJLFNBQVMsR0FBRyxNQUFNLFlBQVksQ0FBQyxHQUF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yxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLG9CQUFvQixDQUFDLENBQUE7WUFDaEQsTUFBTSxPQUFPLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxpREFBaUQsQ0FBQyxDQUFBO1lBRWhGLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyw4QkFBOEIsQ0FBQyxDQUFBO1lBQzFELE1BQU0sT0FBTyxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsbUNBQW1DLENBQUMsQ0FBQTtZQUVsRSxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMseUJBQXlCLENBQUMsQ0FBQTtZQUNyRCxNQUFNLE9BQU8sQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLDBEQUEwRCxDQUFDLENBQUE7UUFDM0YsQ0FBQztRQUNELE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQyxrQ0FBa0MsQ0FBQyxDQUFBO0lBQ2pFLENBQUMsQ0FBQSxDQUFDLENBQUE7SUFFRixZQUFZLENBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFPLE9BQU87UUFDdEQsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsb0JBQW9CLENBQUMsQ0FBQTtRQUMxQyxNQUFNLE9BQU8sQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLGtFQUFrRSxDQUFDLENBQUE7SUFDbkcsQ0FBQyxDQUFBLENBQUMsQ0FBQTtJQUVGLFlBQVksQ0FBQyxVQUFVLEVBQUUsQ0FBQTtBQUMzQixDQUFDLENBQUEifQ==

File diff suppressed because one or more lines are too long

View File

@ -2,21 +2,13 @@
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./npmdocker.plugins");
exports.dockerfileSnippet = (optionsArg) => {
let commandArray = optionsArg.command.split(/\s/);
let commandString = "";
for (let stringItem of commandArray) {
if (!(commandString == "")) {
commandString = commandString + ",";
}
commandString = commandString + '"' + stringItem + '"';
}
;
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"];
`);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQStDO0FBT3BDLFFBQUEsaUJBQWlCLEdBQUcsQ0FBQyxVQUE2QjtJQUN6RCxJQUFJLFlBQVksR0FBRyxVQUFVLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNsRCxJQUFJLGFBQWEsR0FBVSxFQUFFLENBQUM7SUFDOUIsR0FBRyxDQUFBLENBQUMsSUFBSSxVQUFVLElBQUksWUFBWSxDQUFDLENBQUEsQ0FBQztRQUNoQyxFQUFFLENBQUEsQ0FBQyxDQUFDLENBQUMsYUFBYSxJQUFJLEVBQUUsQ0FBQyxDQUFDLENBQUEsQ0FBQztZQUN2QixhQUFhLEdBQUcsYUFBYSxHQUFHLEdBQUcsQ0FBQztRQUN4QyxDQUFDO1FBQ0QsYUFBYSxHQUFHLGFBQWEsR0FBRyxHQUFHLEdBQUcsVUFBVSxHQUFHLEdBQUcsQ0FBQztJQUMzRCxDQUFDO0lBQUEsQ0FBQztJQUNGLE1BQU0sQ0FBQyxPQUFPLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUM7ZUFDakMsVUFBVSxDQUFDLFNBQVM7Ozs7ZUFJcEIsYUFBYTtLQUN2QixDQUFDLENBQUM7QUFDUCxDQUFDLENBQUEifQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQStDO0FBT3BDLFFBQUEsaUJBQWlCLEdBQUcsQ0FBQyxVQUE4QjtJQUM1RCxNQUFNLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDO2VBQy9CLFVBQVUsQ0FBQyxTQUFTOzs7Ozs7S0FNOUIsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFBIn0=

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)
}
})
}
/**

View File

@ -6,19 +6,12 @@ export interface IDockerfileSnippet {
}
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(`
FROM ${optionsArg.baseImage}
RUN yarn global add npmdocker
COPY ./buildContextDir /workspace
WORKDIR /workspace
ENV CI=true
CMD [${commandString}];
`);
CMD ["npmdocker","runinside"];
`)
}