Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
fix test for error throwing. also, tweak test env
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Dec 14, 2017
1 parent 002cd3f commit e75f67d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
tmp
dist

# awesome-typescript-loader
.awcache

# npm
node_modules
npm-debug.log
npm-debug.log
11 changes: 7 additions & 4 deletions tasks/ts-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ gulp.task('ts-types:raw', function() {
})
})

/*
if this task is run at the same time as webpack:watch, it forces webpack:watch to wait
for this to be done for some reason. wait for the initial fullcalendar.js file to be
written (which is when webpack:watch resolves) so that gulp.watch has something to grab
onto, and then watch for changes in the *output* of fullcalendar.js, guaranteeing that
webpack goes first.
*/
gulp.task('ts-types:watch', [ 'webpack:watch' ], function() {
// HACK
// if we watched src/**/*.js files,
// it blocked webpack compilation until dts-generator finished for some reason.
// instead, wait until we know core compilation has finished before rerunning dts-generator.
gulp.watch('dist/fullcalendar.js', [ 'ts-types' ])
})

Expand Down
22 changes: 16 additions & 6 deletions tasks/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ gulp.task('webpack:dev', function() {
return createStream(true)
})

gulp.task('webpack:watch', function() {
createStream(true, true)
/*
this task will be considered done after initial compile
*/
gulp.task('webpack:watch', function(done) {
createStream(true, true, done)
})


const jsFilter = filter([ '**/*.js' ], { restore: true })
const localeFilter = filter([ '**/locale-all.js', '**/locale/*.js' ], { restore: true })

function createStream(enableDev, enableWatch) {
function createStream(isDev, isWatch, doneCallback) {
let doneCallbackCalled = false
let stream = gulp.src([]) // don't pass in any files. webpack handles that
.pipe(
webpack(Object.assign({}, webpackConfig, {
devtool: enableDev ? 'source-map' : false, // also 'inline-source-map'
watch: enableWatch || false
devtool: isDev ? 'source-map' : false, // also 'inline-source-map'
watch: isWatch ? true : false
}))
)
.pipe(
Expand Down Expand Up @@ -62,7 +66,7 @@ function createStream(enableDev, enableWatch) {
}))
.pipe(jsFilter.restore)

if (!enableDev) {
if (!isDev) {
stream = stream
.pipe(localeFilter)
.pipe(uglify()) // uglify only the locale files, then bring back other files to stream
Expand All @@ -72,4 +76,10 @@ function createStream(enableDev, enableWatch) {
return stream.pipe(
gulp.dest(webpackConfig.output.path)
)
.on('data', function() {
if (doneCallback && !doneCallbackCalled) {
doneCallbackCalled = true
setTimeout(doneCallback, 100) // HACK: for some reason files not written an this point, so wait
}
})
}
2 changes: 1 addition & 1 deletion tests/legacy/hiddenDays.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('hiddenDays', function() {
}
expect(function() {
$('#cal').fullCalendar(options)
}).toThrow('invalid hiddenDays')
}).toThrow(new Error('invalid hiddenDays'))
})
})
})
10 changes: 9 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ module.exports = {
rules: [
{
test: /\.(ts|js)$/,
loader: 'awesome-typescript-loader'
loader: 'awesome-typescript-loader',
options: {
useCache: true
}
},
{
test: /\.css$/,
Expand All @@ -83,6 +86,11 @@ module.exports = {
new webpack.BannerPlugin(BANNER)
],

watchOptions: {
aggregateTimeout: 100,
ignored: /node_modules/
},

output: {
library: 'FullCalendar', // gulp will strip this out for plugins
libraryTarget: 'umd',
Expand Down

0 comments on commit e75f67d

Please sign in to comment.