Skip to content

Commit

Permalink
feat: use webpack input filesystem (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Oct 2, 2020
1 parent f2ac763 commit 6f2f455
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ class CopyPlugin {
`getting stats for "${pattern.absoluteFrom}" to determinate "fromType"`
);

const { inputFileSystem } = compiler;

let stats;

try {
stats = await stat(compiler.inputFileSystem, pattern.absoluteFrom);
stats = await stat(inputFileSystem, pattern.absoluteFrom);
} catch (error) {
// Nothing
}
Expand All @@ -110,6 +112,18 @@ class CopyPlugin {
...{ cwd: pattern.context, objectMode: true },
};

// TODO remove after drop webpack@4
if (
inputFileSystem.lstat &&
inputFileSystem.stat &&
inputFileSystem.lstatSync &&
inputFileSystem.statSync &&
inputFileSystem.readdir &&
inputFileSystem.readdirSync
) {
pattern.globOptions.fs = inputFileSystem;
}

switch (pattern.fromType) {
case 'dir':
logger.debug(`determined "${pattern.absoluteFrom}" is a directory`);
Expand Down Expand Up @@ -257,7 +271,7 @@ class CopyPlugin {
let data;

try {
data = await readFile(compiler.inputFileSystem, file.absoluteFrom);
data = await readFile(inputFileSystem, file.absoluteFrom);
} catch (error) {
compilation.errors.push(error);

Expand Down

0 comments on commit 6f2f455

Please # to comment.