tsdocker/ts/tsdocker.config.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-05-10 09:45:20 +00:00
import * as plugins from './tsdocker.plugins';
import * as paths from './tsdocker.paths';
export interface IConfig {
baseImage: string;
command: string;
dockerSock: boolean;
exitCode?: number;
keyValueObject: any[];
}
const getQenvKeyValueObject = async () => {
2019-05-10 09:46:37 +00:00
let qenvKeyValueObjectArray: { [key: string]: string | number };
2019-05-10 09:45:20 +00:00
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObject;
} else {
qenvKeyValueObjectArray = {};
}
return qenvKeyValueObjectArray;
};
2019-05-10 09:46:37 +00:00
const buildConfig = async (qenvKeyValueObjectArg: { [key: string]: string | number }) => {
2019-05-10 09:45:20 +00:00
const npmextra = new plugins.npmextra.Npmextra(paths.cwd);
const config = npmextra.dataFor<IConfig>('npmdocker', {
baseImage: 'hosttoday/ht-docker-node:npmdocker',
init: 'rm -rf node_nodules/ && yarn install',
command: 'npmci npm test',
dockerSock: false,
keyValueObject: qenvKeyValueObjectArg
});
return config;
};
export let run = async (): Promise<IConfig> => {
const config = await getQenvKeyValueObject().then(buildConfig);
return config;
};