2017-02-11 19:23:10 +00:00
|
|
|
import * as plugins from './npmdocker.plugins'
|
|
|
|
import * as paths from "./npmdocker.paths"
|
2016-07-18 22:37:13 +00:00
|
|
|
|
2016-08-04 20:25:15 +00:00
|
|
|
// interfaces
|
2017-02-11 19:23:10 +00:00
|
|
|
import { IKeyValueObject } from 'qenv'
|
2016-08-04 20:25:15 +00:00
|
|
|
|
2016-07-18 22:59:57 +00:00
|
|
|
export interface IConfig {
|
2017-02-11 19:23:10 +00:00
|
|
|
baseImage: string
|
|
|
|
command: string
|
|
|
|
dockerSock: boolean
|
|
|
|
exitCode?: number
|
|
|
|
keyValueObjectArray: IKeyValueObject[]
|
2016-08-04 20:25:15 +00:00
|
|
|
};
|
2016-07-18 22:59:57 +00:00
|
|
|
|
2017-03-28 23:01:37 +00:00
|
|
|
let getQenvKeyValueObject = async () => {
|
2017-02-11 19:23:10 +00:00
|
|
|
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 = []
|
|
|
|
};
|
2017-03-28 23:01:37 +00:00
|
|
|
return qenvKeyValueObjectArray
|
2017-02-11 19:23:10 +00:00
|
|
|
}
|
2016-07-18 22:37:13 +00:00
|
|
|
|
2017-03-28 23:01:37 +00:00
|
|
|
let buildConfig = async (qenvKeyValueObjectArrayArg: IKeyValueObject[]) => {
|
2017-02-11 19:23:10 +00:00
|
|
|
let npmextra = new plugins.npmextra.Npmextra(paths.cwd)
|
|
|
|
let config = npmextra.dataFor<IConfig>(
|
|
|
|
'npmdocker',
|
|
|
|
{
|
2017-04-20 19:57:44 +00:00
|
|
|
baseImage: 'hosttoday/ht-docker-node:npmci',
|
|
|
|
command: 'npmci test stable',
|
2017-02-11 19:23:10 +00:00
|
|
|
dockerSock: false,
|
|
|
|
keyValueObjectArray: qenvKeyValueObjectArrayArg
|
|
|
|
}
|
|
|
|
)
|
2017-03-28 23:01:37 +00:00
|
|
|
return config
|
2017-02-11 19:23:10 +00:00
|
|
|
}
|
2016-08-04 20:25:15 +00:00
|
|
|
|
2017-03-28 23:01:37 +00:00
|
|
|
export let run = async (): Promise<IConfig> => {
|
|
|
|
let config = await getQenvKeyValueObject().then(buildConfig)
|
|
|
|
return config
|
|
|
|
}
|