Skip to content
This repository has been archived by the owner on Nov 20, 2019. It is now read-only.

Commit

Permalink
fix(cli): add --cwd and --ci flags
Browse files Browse the repository at this point in the history
by default it is allowed to run locally and on CI. use --ci to allow running only on CI services and error if ran locally

Signed-off-by: Charlike Mike Reagent <[email protected]>
  • Loading branch information
Charlike Mike Reagent committed Nov 15, 2017
1 parent 6e99e92 commit 57a6319
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"dependencies": {
"detect-next-version": "1.1.3",
"execa-pro": "1.0.2",
"is-ci": "1.0.10",
"latest-version": "3.1.0",
"minimist": "1.2.0",
"parse-git-log": "0.2.1",
"semver": "5.4.1"
},
Expand Down
16 changes: 14 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@

/* eslint-disable no-console */

const isCI = require('is-ci')
const minimist = require('minimist')
const { prepublish, publish } = require('./index.js')

const cwd = process.cwd()
const argv = minimist(process.argv.slice(2), {
default: {
cwd: process.cwd(),
ci: false,
},
})

prepublish(cwd)
if (argv.ci && !isCI) {
console.error('Publishing is only allowed on CI service!')
process.exit(1)
}

prepublish(argv.cwd)
.then((versions) => (versions ? publish(versions.nextVersion) : true))
.catch((er) => {
console.error('new-release error!')
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,7 @@ [email protected]:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"

minimist@^1.2.0:
minimist@1.2.0, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

Expand Down

0 comments on commit 57a6319

Please sign in to comment.