Skip to content

Commit

Permalink
fix: prevent multiple updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Apr 24, 2018
1 parent 5bff463 commit cc872ea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"semver": "^5.5.0"
},
"devDependencies": {
"@oclif/dev-cli": "^1.13.6",
"@oclif/dev-cli": "^1.13.7",
"@oclif/test": "^1.0.5",
"@oclif/tslint": "^1.1.0",
"@types/chai": "^4.1.3",
Expand Down
10 changes: 1 addition & 9 deletions src/get_version.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import * as fs from 'fs-extra'
import HTTP from 'http-call'

async function touch(file: string) {
if (!await fs.pathExists(file)) {
await fs.outputJSON(file, {})
} else {
await fs.utimes(file, new Date(), new Date())
}
}

async function run(name: string, file: string, version: string) {
await touch(file)
await fs.outputJSON(file, {current: version}) // touch file with current version to prevent multiple updates
const {body} = await HTTP.get(`https://registry.npmjs.org/${name.replace('/', '%2f')}`, {timeout: 5000})
await fs.outputJSON(file, {...body['dist-tags'], current: version})
process.exit(0)
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@oclif/command@^1.4.13", "@oclif/command@^1.4.14", "@oclif/command@^1.4.15":
"@oclif/command@^1.4.13", "@oclif/command@^1.4.15":
version "1.4.15"
resolved "https://registry.yarnpkg.com/@oclif/command/-/command-1.4.15.tgz#1886c7dd88a40fbc29427bbca04bdb0e1a538133"
dependencies:
Expand All @@ -40,20 +40,20 @@
dependencies:
debug "^3.1.0"

"@oclif/dev-cli@^1.13.6":
version "1.13.6"
resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.13.6.tgz#9ef12d771acee7a231753b7ef4611603710f3fc3"
"@oclif/dev-cli@^1.13.7":
version "1.13.7"
resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.13.7.tgz#de93aa07d960835a3ff1cad1a3e5f273d96ae926"
dependencies:
"@oclif/command" "^1.4.14"
"@oclif/command" "^1.4.15"
"@oclif/config" "^1.6.13"
"@oclif/errors" "^1.0.6"
"@oclif/plugin-help" "^1.2.5"
cli-ux "^3.3.31"
cli-ux "^3.4.1"
debug "^3.1.0"
fs-extra "^5.0.0"
lodash "^4.17.5"
normalize-package-data "^2.4.0"
qqjs "^0.3.6"
qqjs "^0.3.7"
require-resolve "^0.0.2"
tslib "^1.9.0"

Expand Down Expand Up @@ -338,7 +338,7 @@ clean-stack@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-1.3.0.tgz#9e821501ae979986c46b1d66d2d432db2fd4ae31"

cli-ux@^3.3.31:
cli-ux@^3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-3.4.1.tgz#bfa17e75cd1a60547a11c515166117b05ea89cdd"
dependencies:
Expand Down Expand Up @@ -1252,7 +1252,7 @@ pump@^1.0.0:
end-of-stream "^1.1.0"
once "^1.3.1"

qqjs@^0.3.6:
qqjs@^0.3.7:
version "0.3.7"
resolved "https://registry.yarnpkg.com/qqjs/-/qqjs-0.3.7.tgz#eb7d481d3cf3e8c9744da0d21d917d1a4b2080d9"
dependencies:
Expand Down

0 comments on commit cc872ea

Please sign in to comment.