|
1 | 1 | const path = require('path'), |
2 | 2 | YAML = require('yaml'), |
| 3 | + mkdirp = require('mkdirp'), |
3 | 4 | DrupalLibraryEntryGenerator = require('./DrupalLibraryEntryGenerator'), |
4 | 5 | DrupalLibraryFile = require('./DrupalLibraryFile'), |
5 | 6 | DrupalLibraryMetadata = require('./DrupalLibraryMetadata'), |
@@ -50,13 +51,13 @@ class DrupalLibrariesPlugin { |
50 | 51 | apply(compiler) { |
51 | 52 | // Prevents drupal library dependencies from being included. |
52 | 53 | compiler.hooks.normalModuleFactory.tap('DrupalLibrariesPlugin', cmf => { |
53 | | - cmf.hooks.factory.tap("DrupalLibrariesPlugin", factory => (data, callback) => { |
| 54 | + cmf.hooks.factorize.tapAsync("DrupalLibrariesPlugin", (data, callback) => { |
54 | 55 | const result = this.opts.requirePattern.exec(data.request) |
55 | 56 | if (result) { |
56 | 57 | callback(null, new DrupalLibraryModule(result[1])) |
57 | 58 | } |
58 | 59 | else { |
59 | | - factory(data, callback) |
| 60 | + return callback() |
60 | 61 | } |
61 | 62 | }) |
62 | 63 | }) |
@@ -155,16 +156,15 @@ class DrupalLibrariesPlugin { |
155 | 156 | const content = YAML.stringify(file.content), |
156 | 157 | targetPath = compilation.getPath(file.targetPath) |
157 | 158 |
|
158 | | - compiler.outputFileSystem.mkdirp(path.dirname(targetPath), err => { |
159 | | - if (err) { |
160 | | - throw reject(err.message) |
161 | | - } |
| 159 | + mkdirp(path.dirname(targetPath)).then(() => { |
162 | 160 | compiler.outputFileSystem.writeFile(targetPath, content, err => { |
163 | 161 | if (err) { |
164 | 162 | throw reject(err.message) |
165 | 163 | } |
166 | 164 | accept() |
167 | 165 | }) |
| 166 | + }).catch((err) => { |
| 167 | + throw reject(err.message) |
168 | 168 | }) |
169 | 169 | })) |
170 | 170 | }) |
|
0 commit comments