npmci/ts/npmci.env.ts

46 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

import "typings-global";
import * as plugins from "./npmci.plugins";
import * as paths from "./npmci.paths";
import {GitRepo} from "smartstring";
import {Dockerfile} from "./npmci.build.docker"
export let repo:GitRepo;
if(process.env.CI_BUILD_REPO) repo = new GitRepo(process.env.CI_BUILD_REPO);
2016-06-05 19:11:30 +00:00
export let buildStage:string = process.env.CI_BUILD_STAGE;
2016-06-03 01:44:24 +00:00
// handling config between commands
2016-06-04 23:31:21 +00:00
export let dockerRegistry; // will be set by npmci.prepare
export let dockerFilesBuilt:Dockerfile[] = [];
export let dockerFiles:Dockerfile[] = [];
2016-06-05 21:53:01 +00:00
export let configStore = () => {
2016-06-07 10:36:00 +00:00
let config = {
dockerRegistry: dockerRegistry,
dockerFilesBuilt: dockerFilesBuilt,
dockerFiles: dockerFiles
}
2016-06-05 21:53:01 +00:00
plugins.smartfile.memory.toFsSync(
JSON.stringify(config),
{
fileName:"config.json",
filePath:paths.NpmciPackageRoot
}
);
}
export let configLoad = () => {
2016-06-07 10:36:00 +00:00
let config;
2016-06-05 21:53:01 +00:00
try {
config = plugins.smartfile.local.toObjectSync(paths.NpmciPackageConfig,"json");
}
catch(err){
config = {};
configStore();
2016-06-07 10:36:00 +00:00
plugins.beautylog.log("config initialized!");
2016-06-05 21:53:01 +00:00
}
config.dockerRegistry ? dockerRegistry = config.dockerRegistry : void(0);
config.dockerFilesBuilt ? dockerFilesBuilt = config.dockerFilesBuilt : void(0);
}
2016-06-05 21:53:01 +00:00
configLoad();