2016-07-18 22:37:13 +00:00
|
|
|
import * as plugins from "./npmdocker.plugins";
|
|
|
|
import * as paths from "./npmdocker.paths";
|
|
|
|
|
2016-08-04 20:25:15 +00:00
|
|
|
// interfaces
|
|
|
|
import { IKeyValueObject } from "qenv";
|
|
|
|
|
2016-07-18 22:59:57 +00:00
|
|
|
export interface IConfig {
|
2016-08-04 20:25:15 +00:00
|
|
|
baseImage: string;
|
|
|
|
command: string;
|
|
|
|
dockerSock: boolean;
|
|
|
|
exitCode?: number;
|
|
|
|
keyValueObjectArray: IKeyValueObject[];
|
|
|
|
};
|
2016-07-18 22:59:57 +00:00
|
|
|
|
2016-08-04 20:25:15 +00:00
|
|
|
let getQenvKeyValueObject = () => {
|
|
|
|
let done = plugins.q.defer();
|
|
|
|
let qenvKeyValueObjectArray:IKeyValueObject[];
|
|
|
|
if(plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd,"qenv.yml"))){
|
|
|
|
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, ".nogit/").keyValueObjectArray;
|
|
|
|
} else {
|
|
|
|
qenvKeyValueObjectArray = [];
|
|
|
|
};
|
|
|
|
done.resolve(qenvKeyValueObjectArray);
|
|
|
|
return done.promise;
|
|
|
|
};
|
2016-07-18 22:37:13 +00:00
|
|
|
|
2016-08-04 20:25:15 +00:00
|
|
|
let buildConfig = (qenvKeyValueObjectArrayArg:IKeyValueObject) => {
|
2016-07-18 22:37:13 +00:00
|
|
|
let done = plugins.q.defer();
|
2016-08-04 20:25:15 +00:00
|
|
|
let config: IConfig = plugins.npmextra.dataFor({
|
|
|
|
toolName: "npmdocker",
|
|
|
|
defaultSettings: {
|
|
|
|
baseImage: "hosttoday/ht-docker-node:npmts",
|
|
|
|
command: "npm run npmdocker",
|
|
|
|
dockerSock: false,
|
|
|
|
keyValueObjectArray: qenvKeyValueObjectArrayArg
|
|
|
|
}
|
|
|
|
});
|
2016-07-18 22:37:13 +00:00
|
|
|
done.resolve(config);
|
2016-08-04 20:25:15 +00:00
|
|
|
return done.promise
|
|
|
|
};
|
|
|
|
|
|
|
|
export let run = () => {
|
|
|
|
let done = plugins.q.defer();
|
|
|
|
getQenvKeyValueObject()
|
|
|
|
.then(buildConfig)
|
|
|
|
.then(done.resolve);
|
2016-07-18 22:37:13 +00:00
|
|
|
return done.promise;
|
|
|
|
}
|