Skip to content

Commit

Permalink
chore: switch to pure node editing
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Feb 28, 2020
1 parent 4aa919e commit dabc131
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ jobs:
"password": "1234"
}
]
- name: Look at results
run: |
cat ~/.netrc
39 changes: 27 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
// const exec = require('child_process').exec
const core = require('@actions/core')
// const path = require('path')
const assert = require('nanoassert')
const fs = require('fs')

// const scriptPath = path.resolve(__dirname, 'run.sh')
const creds = JSON.parse(core.getInput('creds'))
assert(Array.isArray(creds), 'creds input must be an array')

const creds = core.getInput('creds')
let credsString = ''

console.log(creds)
creds.forEach(cred => {
assert(cred.machine, 'cred has a machine field')
assert(cred.login, 'cred has a login field')
assert(cred.password, 'cred has a password field')

// exec(`${scriptPath} ${version}`, (error, stdout, stderr) => {
// console.log(stdout)
// console.log(stderr)
// if (error !== null) {
// console.log(`exec error: ${error}`)
// }
// })
let credString = ''

credString += `machine ${cred.machine}\n`
credString += `login ${cred.login}\n`
credString += `password ${cred.password}\n`
credString += '\n'

credsString += credString
})

fs.appendFile('~/.netrc', credsString, err => {
if (err) {
console.error(err)
return core.setFailed(err.message)
}

console.log(`wrote ${creds.length} credentials to ~/.netrc`)
})
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"test": "standard",
"release": "git push --follow-tags && gh-release",
"version": "ncc build index.js -o dist -s && auto-changelog -p --template keepachangelog auto-changelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md dist"
"version": "rm -rf dist && ncc build index.js -o dist -s && auto-changelog -p --template keepachangelog auto-changelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md dist"
},
"repository": {
"type": "git",
Expand All @@ -25,7 +25,8 @@
},
"homepage": "https://github.com/little-core-labs/netrc-creds#readme",
"dependencies": {
"@actions/core": "1.2.2"
"@actions/core": "1.2.2",
"nanoassert": "^2.0.0"
},
"devDependencies": {
"@zeit/ncc": "^0.21.1",
Expand Down
12 changes: 0 additions & 12 deletions run.sh

This file was deleted.

0 comments on commit dabc131

Please sign in to comment.