Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
some changes for excluding certain files
Browse files Browse the repository at this point in the history
  • Loading branch information
KarateCowboy committed May 3, 2017
1 parent 502e3f1 commit b4c8b85
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion commands/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ module.exports = function (topic) {
}

function* push (context, heroku) {
const recurse = !!context.flags.recursive
if(context.args.length === 0 && !recurse){
cli.error('Error: Requires either --recursive or one or more process types')
process.exit(1)
}
let herokuHost = process.env.HEROKU_HOST || 'heroku.com'
let registry = `registry.${ herokuHost }`
let dockerfiles = Sanbashi.getDockerfiles(process.cwd(), true)
let dockerfiles = Sanbashi.getDockerfiles(process.cwd(), recurse)
let possibleJobs = Sanbashi.getJobs(`${ registry }/${ context.app }`, context.args, dockerfiles)
let jobs = yield Sanbashi.chooseJobs(possibleJobs)
if (!jobs.length) {
Expand Down
5 changes: 5 additions & 0 deletions lib/sanbashi.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// 'sanbashi' is a word in Japanese that refers to a pier or dock, usually very large in size, such as found in Tokyo's O-daiba region

let Glob = require('glob')
let Path = require('path')
let Inquirer = require('inquirer')
Expand All @@ -15,6 +17,9 @@ class Sanbashi {
nonull: false,
nodir: true
})
if(recursive){
dockerfiles = dockerfiles.filter(df => df.match(/Dockerfile\.[\w]+/))
}
return dockerfiles.map(file => Path.join(rootdir, file))
}

Expand Down
Empty file.
7 changes: 6 additions & 1 deletion test/sanbashi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ describe('Sanbashi', () => {
it('can recurse the directory', () => {
const searchpath = Path.join(process.cwd(), './test/fixtures')
let results = Sanbashi.getDockerfiles(searchpath, true)
expect(results).to.have.members([`${searchpath}/Dockerfile.web`, `${searchpath}/Nested/Dockerfile`])
expect(results).to.have.members([`${searchpath}/Dockerfile.web`, `${searchpath}/Nested/Dockerfile.web`])
})
it('when recursing, rejects dockerfiles that have no postfix in the name', () => {
const searchpath = Path.join(process.cwd(), './test/fixtures')
let results = Sanbashi.getDockerfiles(searchpath, true)
expect(results).to.not.have.members([`${searchpath}/Dockerfile`])
})
})
describe('.getJobs', () => {
Expand Down

0 comments on commit b4c8b85

Please sign in to comment.