Skip to content

Commit

Permalink
feat: setup travis-deploy-once locally
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Jan 8, 2018
1 parent 95271c6 commit b42aaab
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lib/travis.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const inquirer = require('inquirer');
const Travis = require('travis-ci');
const yaml = require('js-yaml');
const log = require('npmlog');
const request = require('request-promise').defaults({json: true});

const travisyml = {
language: 'node_js',
Expand All @@ -20,7 +21,7 @@ const travisyml = {
},
// https://github.com/nodejs/Release#release-schedule
node_js: ['9', '8', '6', '4'], // eslint-disable-line camelcase
after_success: ['npm install -g travis-deploy-once@4', 'travis-deploy-once "npm run semantic-release"'], // eslint-disable-line camelcase
after_success: ['npm run travis-deploy-once "npm run semantic-release"'], // eslint-disable-line camelcase
branches: {
// ignore git tags created by semantic-release, like "v1.2.3"
except: [/^v\d+\.\d+\.\d+$/.toString()],
Expand Down Expand Up @@ -123,6 +124,19 @@ async function setUpTravis(pkg, info) {

log.info('Successfully set environment variables on Travis CI.');
await createTravisYml(info);

pkg.scripts['travis-deploy-once'] = 'travis-deploy-once';

try {
const {'dist-tags': distTags} = await request('https://registry.npmjs.org/travis-deploy-once');
pkg.devDependencies = pkg.devDependencies || {};
pkg.devDependencies['travis-deploy-once'] = `^${distTags[info.options.tag]}`;
} catch (err) {
log.error('Could not get latest `travis-deploy-once` version.', err);
}

log.verbose('Writing `package.json`.');
writeFileSync('package.json', `${JSON.stringify(pkg, null, 2)}\n`);
}

module.exports = async function(endpoint, pkg, info) {
Expand Down

0 comments on commit b42aaab

Please sign in to comment.