diff --git a/__mocks__/aws-sdk.js b/__mocks__/aws-sdk.js new file mode 100644 index 0000000..99afbd8 --- /dev/null +++ b/__mocks__/aws-sdk.js @@ -0,0 +1,4 @@ +/* global jest */ + +const AWS = module.exports = jest.genMockFromModule('aws-sdk') +AWS.S3.prototype.upload = () => ({send: (fn) => fn()}) diff --git a/__tests__/lib/__snapshots__/test.js.snap b/__tests__/lib/__snapshots__/test.js.snap index 3de476d..29046e5 100644 --- a/__tests__/lib/__snapshots__/test.js.snap +++ b/__tests__/lib/__snapshots__/test.js.snap @@ -19,6 +19,7 @@ Object { "another-folder", ], "coverageDirectory": "coverage", + "notify": true, "setupFiles": Array [ "beforeTestsSetup.js", ], diff --git a/bin/mastarm b/bin/mastarm index ae878aa..3ba77b0 100755 --- a/bin/mastarm +++ b/bin/mastarm @@ -12,7 +12,6 @@ commander .option('-e, --env ', 'Environment to use.') .option('-m, --minify', 'Minify built files.') .option('-O, --outdir ', 'Publish directory', '') - .option('-S, --skip-check-dependencies', '**DEPRECATED**') commander .command('build [entries...]') @@ -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) }) diff --git a/lib/__tests__/push-to-s3.js b/lib/__tests__/push-to-s3.js new file mode 100644 index 0000000..914abb4 --- /dev/null +++ b/lib/__tests__/push-to-s3.js @@ -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`]) + ]) + }) +}) diff --git a/lib/push-to-s3.js b/lib/push-to-s3.js index 92b5c12..de6a45f 100644 --- a/lib/push-to-s3.js +++ b/lib/push-to-s3.js @@ -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) { @@ -72,8 +72,8 @@ function upload ({ ] } } - }, function (err, data) { - if (err) reject(err) + }, function (err) { + if (err) return reject(err) done() }) } else { diff --git a/lib/test.js b/lib/test.js index 43fe4f7..c985822 100644 --- a/lib/test.js +++ b/lib/test.js @@ -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: ['/node_modules/', '/__tests__/test-utils'] } @@ -41,5 +42,6 @@ module.exports.generateTestConfig = (patterns, options) => { if (patterns) { jestArguments = jestArguments.concat(patterns) } + return jestArguments } diff --git a/package.json b/package.json index 4bfb18e..839ea91 100644 --- a/package.json +++ b/package.json @@ -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",