Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows command runner #20

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
coverage
test/home/.config
test/home/builds
.nyc_output
node_modules/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ gcr - a gitlab ci runner
-k, --keypath <path> specify path to rsa key
-s, --shell <path> specify path to shell e.g. /bin/bash
-sf, --shellFlag <flag> set the flag to run commands on your shell e.g. -c
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need single character only for - flags.

-C, --sslcert <path> enable/disable strict ssl
-K, --sslkey <path> run npm install/test if no commands are present
-A, --cacert <path> specify path to rsa key
```

## Execution Notes
Expand Down
6 changes: 6 additions & 0 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ var gcr = require('../lib/gcr')
, keypath: path
, shell: path
, shellFlag: String
, sslcert: path
, sslkey: path
, cacert: path
}
, shortHand = { verbose: ['--loglevel', 'verbose']
, h: ['--help']
Expand All @@ -36,6 +39,9 @@ var gcr = require('../lib/gcr')
, k: ['--keypath']
, s: ['--shell']
, sf: ['--shellFlag']
, C: ['--sslcert']
, K: ['--sslkey']
, A: ['--cacert']
}
, parsed = nopt(knownOpts, shortHand)

Expand Down
3 changes: 3 additions & 0 deletions bin/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ gcr - a gitlab ci runner
-k, --keypath <path> specify path to rsa key
-s, --shell <path> specify path to shell e.g. /bin/bash
-sf, --shellFlag <flag> set the flag to run commands on your shell e.g. -c
-C, --sslcert <path> enable/disable strict ssl
-K, --sslkey <path> run npm install/test if no commands are present
-A, --cacert <path> specify path to rsa key
7 changes: 6 additions & 1 deletion lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ Build.prototype.runCommand = function(cmd, dir, cb) {
log.verbose('[builder]', 'cmd', cmd)
this.append(`\n${cmd}\n`)

var child = spawn(gcr.config.get('shell'), [gcr.config.get('shellFlag'), fixedCmd.join(' ')], opts)
const child = spawn(
gcr.config.get('shell')
, [gcr.config.get('shellFlag')
, fixedCmd.join(' ')]
, opts
)
var timedout = false
var timer = setTimeout(() => {
timedout = true
Expand Down
12 changes: 10 additions & 2 deletions lib/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ module.exports = function(parsed) {
? parsed.strictSSL
: true

o.shell = parsed.shell ? parsed.shell : isWin ? 'C:\\Windows\\System32\\cmd.exe' : '/bin/bash'
o.shellFlag = parsed.shellFlag ? parsed.shellFlag : isWin ? '/C' : '-c'
o.shell = parsed.shell
? parsed.shell
: isWin
? 'C:\\Windows\\System32\\cmd.exe'
: '/bin/bash'
o.shellFlag = parsed.shellFlag
? parsed.shellFlag
: isWin
? '/C'
: '-c'
return o
}
14 changes: 11 additions & 3 deletions lib/gcr.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ log.heading = 'gcr'

module.exports = gcr

gcr.confFile = confFile
gcr.root = path.dirname(gcr.confFile)
gcr.root = path.dirname(confFile)
gcr.loaded = false
gcr.version = require('../package').version

Expand All @@ -32,7 +31,7 @@ gcr.load = function(opts, cb) {
err.heading = '[mkdirp]'
return cb(err)
}
nconf.file({ file: gcr.confFile })
nconf.file({ file: confFile })
nconf.defaults(require('./config.default')(opts))
if (opts.url) {
nconf.set('url', opts.url)
Expand Down Expand Up @@ -64,6 +63,15 @@ gcr.load = function(opts, cb) {
if (opts.shellFlag) {
nconf.set('shellFlag', opts.shellFlag)
}
if (opts.sslcert) {
nconf.set('sslcert', opts.sslcert)
}
if (opts.sslkey) {
nconf.set('sslkey', opts.sslkey)
}
if (opts.cacert) {
nconf.set('cacert', opts.cacert)
}
gcr.config = nconf
chain([
validateGit
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.