-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix duplicate queries.json file generation
Closes #145
- Loading branch information
1 parent
4b007de
commit 165f3fb
Showing
3 changed files
with
43 additions
and
4 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,25 @@ | ||
const fs = require('fs'); | ||
|
||
class MoveFilePlugin { | ||
|
||
/** | ||
* Create a new instance of the MoveFilePlugin. | ||
* This plugin expects two functions as arguments, because the paths will be different at runtime. | ||
* @param getSource method to retrieve the source file path | ||
* @param getDestination method to retrieve the destination file path | ||
*/ | ||
constructor(getSource, getDestination) { | ||
this.getSource = getSource; | ||
this.getDestination = getDestination; | ||
} | ||
|
||
apply(compiler) { | ||
compiler.hooks.afterEmit.tap('MoveFilePlugin', (compilation) => { | ||
if (fs.existsSync(this.getSource())) { | ||
fs.renameSync(this.getSource(), this.getDestination()); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
module.exports = MoveFilePlugin; |
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