Skip to content

Commit

Permalink
Merge pull request #99 from conveyal/dev
Browse files Browse the repository at this point in the history
v3.1.1
  • Loading branch information
trevorgerhardt authored Dec 5, 2016
2 parents 635464d + 811f874 commit c8f47d2
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
4 changes: 4 additions & 0 deletions __mocks__/aws-sdk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* global jest */

const AWS = module.exports = jest.genMockFromModule('aws-sdk')
AWS.S3.prototype.upload = () => ({send: (fn) => fn()})
1 change: 1 addition & 0 deletions __tests__/lib/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Object {
"another-folder",
],
"coverageDirectory": "coverage",
"notify": true,
"setupFiles": Array [
"beforeTestsSetup.js",
],
Expand Down
4 changes: 2 additions & 2 deletions bin/mastarm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ commander
.option('-e, --env <environment>', 'Environment to use.')
.option('-m, --minify', 'Minify built files.')
.option('-O, --outdir <dir>', 'Publish directory', '')
.option('-S, --skip-check-dependencies', '**DEPRECATED**')

commander
.command('build [entries...]')
Expand Down Expand Up @@ -77,9 +76,10 @@ commander
minify: get('minify'),
s3bucket: get('s3bucket')
}))).then(() => {
console.log('Finished pushing to s3')
console.log('Finished deploying!')
process.exit(0)
}).catch((err) => {
console.error('Error while deploying!')
console.error(err.stack)
process.exit(1)
})
Expand Down
23 changes: 23 additions & 0 deletions lib/__tests__/push-to-s3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* global describe, it */

const BUILD_DIR = '__tests__/test-utils/tmp'
const MOCK_DIR = '__tests__/test-utils/mocks'

describe('lib > push to s3', () => {
const configPush = require('../push-to-s3')
const loadConfig = require('../load-config')

it('should compile JavaScript and CSS and send to s3 via aws-sdk', () => {
const config = loadConfig(process.cwd(), '~/mastarm/configurations/default', 'test')
const push = configPush({
env: 'test',
config,
minify: false,
s3bucket: 'test-bucket'
})
return Promise.all([
push([`${MOCK_DIR}/index.js`, `${BUILD_DIR}/index.js`]),
push([`${MOCK_DIR}/index.css`, `${BUILD_DIR}/index.css`])
])
})
})
8 changes: 4 additions & 4 deletions lib/push-to-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function upload ({
console.log('building and pushing %s to s3 bucket %s', outfile, bucket)
s3object
.upload()
.send(function (err, data) {
if (err) reject(err)
.send(function (err) {
if (err) return reject(err)
console.log('finished pushing %s to s3', outfile)

if (cloudfront) {
Expand All @@ -72,8 +72,8 @@ function upload ({
]
}
}
}, function (err, data) {
if (err) reject(err)
}, function (err) {
if (err) return reject(err)
done()
})
} else {
Expand Down
2 changes: 2 additions & 0 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports.generateTestConfig = (patterns, options) => {
collectCoverage: options.coverage,
collectCoverageFrom: ['lib/**/*.js'],
coverageDirectory: 'coverage',
notify: true,
transform: { '.*': path.resolve(__dirname, 'jest-preprocessor.js') },
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/__tests__/test-utils']
}
Expand Down Expand Up @@ -41,5 +42,6 @@ module.exports.generateTestConfig = (patterns, options) => {
if (patterns) {
jestArguments = jestArguments.concat(patterns)
}

return jestArguments
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"mkdirp": "^0.5.1",
"postcss": "^5.0.21",
"postcss-cssnext": "^2.6.0",
"postcss-import": "^8.1.2",
"postcss-import": "^9.0.0",
"postcss-reporter": "^2.0.0",
"postcss-safe-parser": "^2.0.0",
"rimraf": "^2.5.4",
Expand Down

0 comments on commit c8f47d2

Please sign in to comment.