tsdocker/ts/npmdocker.config.ts

49 lines
1.3 KiB
TypeScript
Raw Normal View History

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
2016-08-04 20:25:15 +00:00
let getQenvKeyValueObject = () => {
2017-02-11 19:23:10 +00:00
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
2017-02-11 19:23:10 +00:00
let buildConfig = (qenvKeyValueObjectArrayArg: IKeyValueObject) => {
let done = plugins.q.defer()
let npmextra = new plugins.npmextra.Npmextra(paths.cwd)
let config = npmextra.dataFor<IConfig>(
'npmdocker',
{
baseImage: 'hosttoday/ht-docker-node:npmts',
command: 'npm test',
dockerSock: false,
keyValueObjectArray: qenvKeyValueObjectArrayArg
}
)
done.resolve(config)
return done.promise
}
2016-08-04 20:25:15 +00:00
export let run = () => {
2017-02-11 19:23:10 +00:00
let done = plugins.q.defer()
getQenvKeyValueObject()
.then(buildConfig)
.then(done.resolve)
return done.promise
2016-07-18 22:37:13 +00:00
}