diff --git a/src/scripts/release.js b/src/scripts/release.js index 580816f..ffc283f 100644 --- a/src/scripts/release.js +++ b/src/scripts/release.js @@ -1,8 +1,8 @@ const debug = require('debug')('frans:release'); -const { isNil, prop } = require('ramda'); +const { isNil, prop, has } = require('ramda'); const { toCamelCase } = require('strman'); const hijackCosmiconfig = require('../utils/hijack-cosmiconfig'); -const { hasPkgProp } = require('../utils'); +const { hasPkgProp, parseEnv } = require('../utils'); const convertArgs = args => { const getProp = p => prop(p, args); @@ -29,14 +29,26 @@ function release(configPath) { return async args => { debug('Setup script release'); + const hasArg = p => has(p, args); + const useBuiltinConfig = configPath != null && !hasPkgProp('release'); debug(`Use builtin config: ${useBuiltinConfig}`); + const runRelease = + !hasArg('dry-run') && + parseEnv('TRAVIS', false) && + process.env.TRAVIS_BRANCH === 'master' && + !parseEnv('TRAVIS_PULL_REQUEST', false); + debug(`Run release: ${runRelease}`); + if (useBuiltinConfig) { await hijackCosmiconfig('semantic-release', configPath, 'release'); } - const convertedArgs = convertArgs(args); + const convertedArgs = convertArgs({ ...args, dryRun: !runRelease }); + + debug('Call semantic release'); + debug('With args: %o', convertedArgs); return require('semantic-release')(convertedArgs); }; }