Skip to content

Commit 55a50f3

Browse files
committed
work on bin
1 parent 55b6f43 commit 55a50f3

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

bin/empty.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env node
2+
3+
const parse = require('parse-github-repo-url')
4+
const emptyGitHubCommit = require('..')
5+
6+
const token = process.env.TOKEN || process.env.GITHUB_TOKEN
7+
if (!token) {
8+
console.error('Cannot find TOKEN or GITHUB_TOKEN')
9+
process.exit(1)
10+
}
11+
const repoWhat = process.argv[2]
12+
const message = process.argv[3]
13+
if (!repoWhat || !message) {
14+
repoWhat.log('usage: empty-commit <repo url> <commit message>')
15+
process.exit(1)
16+
}
17+
console.log('Making empty commit in', repoWhat)
18+
console.log('message:', message)
19+
20+
const parsed = parse(repoWhat)
21+
const user = parsed[0]
22+
const repo = parsed[1]
23+
if (!user || !repo) {
24+
console.error('Could not parse repo', repoWhat)
25+
process.exit(1)
26+
}
27+
28+
emptyGitHubCommit({
29+
owner: user,
30+
repo: repo,
31+
token: process.env.TOKEN,
32+
fullyQualifiedRef: 'heads/master'
33+
}).then(console.log, e => {
34+
console.error(e)
35+
process.exit(1)
36+
})

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
"engines": {
2828
"node": ">=6"
2929
},
30+
"alias": {
31+
"empty": "bin/empty.js",
32+
"make-empty": "bin/empty.js",
33+
"empty-commit": "bin/empty.js"
34+
},
3035
"files": [
36+
"bin/*.js",
3137
"src/*.js",
3238
"!src/*-spec.js"
3339
],
@@ -54,10 +60,10 @@
5460
"deps": "deps-ok && dependency-check --no-dev .",
5561
"issues": "git-issues",
5662
"license": "license-checker --production --onlyunknown --csv",
57-
"lint": "standard --verbose --fix src/*.js",
63+
"lint": "standard --verbose --fix src/*.js bin/*.js",
5864
"prelint": "npm run pretty",
5965
"pretest": "npm run lint",
60-
"pretty": "prettier-standard 'src/*.js'",
66+
"pretty": "prettier-standard 'src/*.js' 'bin/*.js'",
6167
"secure": "nsp check",
6268
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
6369
"test": "npm run unit",
@@ -82,6 +88,7 @@
8288
},
8389
"dependencies": {
8490
"debug": "3.1.0",
85-
"github": "11.0.0"
91+
"github": "11.0.0",
92+
"parse-github-repo-url": "1.4.1"
8693
}
8794
}

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var updateRefrence = function (data) {
8787
})
8888
}
8989

90-
function commitToGithub (opts) {
90+
function emptyGitHubCommit (opts) {
9191
opts = opts || {}
9292
if (!opts.owner || !opts.repo) {
9393
console.error('missing owner or repo')
@@ -103,7 +103,7 @@ function commitToGithub (opts) {
103103
}
104104
data.owner = opts.owner
105105
data.repo = opts.repo
106-
data.fullyQualifiedRef = opts.fullyQualifiedRef || 'heads/dev'
106+
data.fullyQualifiedRef = opts.fullyQualifiedRef || 'heads/master'
107107
data.forceUpdate = opts.forceUpdate || false
108108
data.commitMessage =
109109
opts.commitMessage || 'AutoCommit - ' + new Date().getTime().toString()
@@ -118,11 +118,11 @@ function commitToGithub (opts) {
118118
})
119119
}
120120

121-
module.exports = commitToGithub
121+
module.exports = emptyGitHubCommit
122122

123123
if (!module.parent) {
124124
console.log('demo commit')
125-
commitToGithub({
125+
emptyGitHubCommit({
126126
owner: 'bahmutov',
127127
repo: 'commit-to-github',
128128
token: process.env.TOKEN,

0 commit comments

Comments
 (0)