-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: promisify the in-memory compiler and remove redundant tests
- Loading branch information
Showing
3 changed files
with
47 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
var webpack = require('webpack'); | ||
var MemoryFileSystem = require('memory-fs'); | ||
|
||
var outputFileSystem = new MemoryFileSystem(); | ||
|
||
/** | ||
* Basic in memory compiler, promisified | ||
* @param testConfig - the plugin config being tested run through the webpack compiler | ||
* @return {Promise} - rejects with both stats and the error if needed | ||
*/ | ||
module.exports = function pack(testConfig) { | ||
return new Promise(function (resolve, reject) { | ||
var compiler = webpack(testConfig); | ||
compiler.outputFileSystem = outputFileSystem; | ||
compiler.run(function (err, stats) { | ||
if (err) { | ||
return reject({err: err, stats: stats}); | ||
} | ||
return resolve(stats); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters