From 2f4fb28b5d8366ac40242a19c7a7293af57a08d1 Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Wed, 23 Mar 2016 15:47:28 +0100 Subject: [PATCH] made options handling easier --- dist/npmts.jsdoc.js | 2 +- dist/npmts.options.js | 26 ++++++++++++++------------ ts/npmts.jsdoc.ts | 2 +- ts/npmts.options.ts | 29 ++++++++++++++++------------- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/dist/npmts.jsdoc.js b/dist/npmts.jsdoc.js index 3cd8c7a..b0cc7d7 100644 --- a/dist/npmts.jsdoc.js +++ b/dist/npmts.jsdoc.js @@ -34,7 +34,7 @@ var publishDocs = function (configArg) { + "&& git push --force --quiet " + "\"" + gitUrl + "\" " + "master:gh-pages " + "> /dev/null 2>&1"; - if (plugins.smartenv.getEnv().isTravis && configArg.docs && configArg.docs.publish) { + if (configArg.docs.publish) { plugins.beautylog.log("now publishing JsDoc documentation to GitHub"); if (!plugins.shelljs.which('git')) { plugins.beautylog.error('Git is not installed!'); diff --git a/dist/npmts.options.js b/dist/npmts.options.js index 0e29491..b5ff777 100644 --- a/dist/npmts.options.js +++ b/dist/npmts.options.js @@ -2,12 +2,12 @@ /// var plugins = require("./npmts.plugins"); exports.isRelease = function () { - if (plugins.smartci.check.isCi() && plugins.smartci.check.isTaggedCommit()) { - return true; - } - else { - return false; - } + return plugins.smartci.check.isCi() + && plugins.smartci.check.isTaggedCommit(); +}; +exports.doPublish = function () { + return exports.isRelease() + && plugins.smartci.get.subJobNumber() != 1; }; exports.run = function (configArg) { var done = plugins.Q.defer(); @@ -26,13 +26,15 @@ exports.run = function (configArg) { config.test = ["./index.js"]; } // handle state of current build - exports.isRelease() ? plugins.beautylog.info("All right this is a release build!") - : plugins.beautylog.info("not a release build!"); + exports.isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!") + : plugins.beautylog.info("NOT A RELEASE build! We are not publishing anything!"); // handle coveralls - if ((typeof config.coveralls === "undefined" || !exports.isRelease()) - && plugins.smartci.get.subJobNumber == 1) { - config.coveralls = false; - } + config.coveralls ? void (0) : config.coveralls = false; + exports.doPublish() ? void (0) : config.coveralls = false; + // handle docs + config.docs ? void (0) : config.docs = {}; + config.docs.publish ? void (0) : config.docs.publish = false; + exports.doPublish() ? void (0) : config.docs.publish = false; done.resolve(config); return done.promise; var _a; diff --git a/ts/npmts.jsdoc.ts b/ts/npmts.jsdoc.ts index 4c34f82..3bf19fe 100644 --- a/ts/npmts.jsdoc.ts +++ b/ts/npmts.jsdoc.ts @@ -40,7 +40,7 @@ var publishDocs = function(configArg){ + "\"" + gitUrl + "\" " + "master:gh-pages " + "> /dev/null 2>&1"; - if(plugins.smartenv.getEnv().isTravis && configArg.docs && configArg.docs.publish){ + if(configArg.docs.publish){ plugins.beautylog.log("now publishing JsDoc documentation to GitHub"); if (!plugins.shelljs.which('git')) { plugins.beautylog.error('Git is not installed!'); diff --git a/ts/npmts.options.ts b/ts/npmts.options.ts index dfcde36..530b9d8 100644 --- a/ts/npmts.options.ts +++ b/ts/npmts.options.ts @@ -2,11 +2,13 @@ import plugins = require("./npmts.plugins"); export let isRelease = function():boolean { - if (plugins.smartci.check.isCi() && plugins.smartci.check.isTaggedCommit()){ - return true; - } else { - return false; - } + return plugins.smartci.check.isCi() + && plugins.smartci.check.isTaggedCommit(); +}; + +export let doPublish = function():boolean { + return isRelease() + && plugins.smartci.get.subJobNumber() != 1; }; export var run = function(configArg){ @@ -29,16 +31,17 @@ export var run = function(configArg){ // handle state of current build - isRelease() ? plugins.beautylog.info("All right this is a release build!") - : plugins.beautylog.info("not a release build!"); + isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!") + : plugins.beautylog.info("NOT A RELEASE build! We are not publishing anything!"); // handle coveralls - if ( - (typeof config.coveralls === "undefined" || !isRelease()) - && plugins.smartci.get.subJobNumber == 1 - ){ - config.coveralls = false; - } + config.coveralls ? void(0) : config.coveralls = false; + doPublish() ? void(0) : config.coveralls = false; + + // handle docs + config.docs ? void(0) : config.docs = {}; + config.docs.publish ? void(0) : config.docs.publish = false; + doPublish() ? void(0) : config.docs.publish = false; done.resolve(config); return done.promise;