npmci/dist/mod_npm/index.js

68 lines
4.6 KiB
JavaScript
Raw Normal View History

2017-08-27 13:24:17 +00:00
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./mod.plugins");
const npmci_bash_1 = require("../npmci.bash");
/**
* handle cli input
* @param argvArg
*/
exports.handleCli = (argvArg) => __awaiter(this, void 0, void 0, function* () {
if (argvArg._.length >= 2) {
let action = argvArg._[1];
switch (action) {
case 'install':
yield install();
break;
case 'prepare':
yield prepare();
break;
case 'test':
yield exports.test();
break;
default:
plugins.beautylog.error(`>>npmci node ...<< action >>${action}<< not supported`);
}
}
else {
plugins.beautylog.log(`>>npmci node ...<< cli arguments invalid... Please read the documentation.`);
}
});
/**
* authenticates npm with token from env var
*/
let prepare = () => __awaiter(this, void 0, void 0, function* () {
let npmrcPrefix = '//registry.npmjs.org/:_authToken=';
let npmToken = process.env.NPMCI_TOKEN_NPM;
let npmrcFileString = npmrcPrefix + npmToken;
if (npmToken) {
plugins.beautylog.info('found access token');
}
else {
plugins.beautylog.error('no access token found! Exiting!');
process.exit(1);
}
plugins.smartfile.memory.toFsSync(npmrcFileString, '/root/.npmrc');
return;
});
let install = () => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.info('now installing dependencies:');
if (yield npmci_bash_1.yarnAvailable.promise) {
yield npmci_bash_1.bash('yarn install');
}
else {
yield npmci_bash_1.bash('npm install');
}
});
exports.test = () => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.info('now starting tests:');
yield npmci_bash_1.bash('yarn test');
});
//# sourceMappingURL=data:application/json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