tscoverage/ts/npmts.configfile.ts

27 lines
1.0 KiB
TypeScript
Raw Normal View History

2016-05-19 20:11:18 +00:00
/// <reference path="./typings/index.d.ts" />
2016-02-19 23:53:23 +00:00
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
export var run = function(){
2016-02-22 21:22:39 +00:00
var done = plugins.Q.defer();
2016-02-19 23:53:23 +00:00
var config:any = {};
var configPath = plugins.path.join(paths.cwd,"npmts.json");
if(plugins.smartfile.checks.fileExistsSync(configPath)){
plugins.beautylog.info("npmts.json".blue + " config file found!");
2016-03-20 18:09:58 +00:00
config = plugins.smartfile.local.toObjectSync(configPath);
2016-02-19 23:53:23 +00:00
switch (config.mode){
case "default":
case "custom":
2016-04-01 23:20:52 +00:00
plugins.beautylog.ok("mode is " + config.mode.yellow);
2016-02-19 23:53:23 +00:00
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
2016-03-12 09:21:16 +00:00
process.exit(1);
2016-02-09 04:39:31 +00:00
};
2016-02-19 23:53:23 +00:00
} else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
config.mode = "default";
done.resolve(config);
};
return done.promise;
};