2016-03-12 09:21:16 +00:00
|
|
|
"use strict";
|
2016-05-25 03:23:48 +00:00
|
|
|
require("typings-global");
|
2016-02-19 23:53:23 +00:00
|
|
|
var plugins = require("./npmts.plugins");
|
|
|
|
var paths = require("./npmts.paths");
|
2016-06-16 01:02:33 +00:00
|
|
|
exports.run = function (argvArg) {
|
2016-02-22 21:22:39 +00:00
|
|
|
var done = plugins.Q.defer();
|
2016-02-19 23:53:23 +00:00
|
|
|
var config = {};
|
|
|
|
var configPath = plugins.path.join(paths.cwd, "npmts.json");
|
2016-06-16 01:02:33 +00:00
|
|
|
if (argvArg.notest) {
|
|
|
|
config.notest = true;
|
|
|
|
}
|
2016-07-01 00:28:34 +00:00
|
|
|
if (plugins.smartfile.fs.fileExistsSync(configPath)) {
|
2016-02-19 23:53:23 +00:00
|
|
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
2016-07-01 00:28:34 +00:00
|
|
|
config = plugins.lodashObject.assign(config, plugins.smartfile.fs.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-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;
|
|
|
|
};
|