now using npmextra

This commit is contained in:
Philipp Kunz 2016-07-17 17:13:47 +02:00
parent 8104609306
commit 3c7f5f1e2d
6 changed files with 56 additions and 52 deletions

View File

@ -2,16 +2,23 @@
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.run = function (argvArg) {
var done = plugins.Q.defer();
var config = {};
var configPath = plugins.path.join(paths.cwd, "npmts.json");
npmts_promisechain_1.npmtsOra.text("looking for npmextra.json");
var defaultConfig = {
mode: "default",
notest: false
};
if (argvArg.notest) {
config.notest = true;
defaultConfig.notest = true;
}
if (plugins.smartfile.fs.fileExistsSync(configPath)) {
plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.lodashObject.assign(config, plugins.smartfile.fs.toObjectSync(configPath));
;
var config = plugins.npmextra.dataFor({
toolName: "npmts",
defaultSettings: defaultConfig,
cwd: paths.cwd
});
switch (config.mode) {
case "default":
case "custom":
@ -23,12 +30,6 @@ exports.run = function (argvArg) {
process.exit(1);
}
;
}
else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
config.mode = "default";
done.resolve(config);
}
;
return done.promise;
};

View File

@ -12,6 +12,7 @@ export declare let g: {
typedoc: any;
};
export declare let lodashObject: any;
export import npmextra = require("npmextra");
export import projectinfo = require("projectinfo");
export import path = require("path");
export import Q = require("q");

View File

@ -13,6 +13,7 @@ exports.g = {
typedoc: require("gulp-typedoc")
};
exports.lodashObject = require('lodash/fp/object');
exports.npmextra = require("npmextra");
exports.projectinfo = require("projectinfo");
exports.path = require("path");
exports.Q = require("q");

View File

@ -29,9 +29,9 @@
},
"homepage": "https://gitlab.com/pushrocks/npmts#readme",
"dependencies": {
"@types/minimatch": "*",
"@types/q": "*",
"@types/shelljs": "*",
"@types/minimatch": "^2.0.28",
"@types/q": "^0.0.27",
"@types/shelljs": "^0.3.27",
"babel-preset-es2015": "^6.9.0",
"beautylog": "5.0.14",
"early": "^2.0.13",
@ -47,6 +47,7 @@
"gulp-sourcemaps": "^1.6.0",
"gulp-typedoc": "^2.0.0",
"lodash": "^4.13.1",
"npmextra": "^1.0.7",
"projectinfo": "1.0.3",
"q": "^1.4.1",
"shelljs": "^0.7.0",

View File

@ -1,19 +1,22 @@
import "typings-global";
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
import {npmtsOra} from "./npmts.promisechain";
export var run = function(argvArg){
var done = plugins.Q.defer();
var config:any = {};
var configPath = plugins.path.join(paths.cwd,"npmts.json");
let done = plugins.Q.defer();
npmtsOra.text("looking for npmextra.json");
let defaultConfig = {
mode: "default",
notest:false
};
if(argvArg.notest){
config.notest = true;
}
if(plugins.smartfile.fs.fileExistsSync(configPath)){
plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.lodashObject.assign(
config,
plugins.smartfile.fs.toObjectSync(configPath)
);
defaultConfig.notest = true;
};
let config = plugins.npmextra.dataFor({
toolName:"npmts",
defaultSettings:defaultConfig,
cwd:paths.cwd
});
switch (config.mode){
case "default":
case "custom":
@ -24,10 +27,6 @@ export var run = function(argvArg){
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
};
} else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
config.mode = "default";
done.resolve(config);
};
return done.promise;
};

View File

@ -12,6 +12,7 @@ export let g = {
typedoc: require("gulp-typedoc")
};
export let lodashObject = require('lodash/fp/object');
export import npmextra = require("npmextra");
export import projectinfo = require("projectinfo");
export import path = require("path");
export import Q = require("q");