-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to gh-pages from @ a7acf17 🚀
- Loading branch information
Showing
10 changed files
with
126 additions
and
60 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,47 @@ | ||
import path from 'path'; | ||
import fsPromise from 'fs/promises'; | ||
import chokidar from 'chokidar'; | ||
|
||
export function copy({watch, transformFn = v => v}) { | ||
return new Promise(resolve => { | ||
const outDir = 'out'; | ||
|
||
async function copyFile(srcFilename) { | ||
const dstFilename = path.join(outDir, srcFilename); | ||
const dirname = path.dirname(dstFilename); | ||
try { | ||
await fsPromise.stat(dirname); | ||
} catch { | ||
await fsPromise.mkdir(dirname, { recursive: true }); | ||
} | ||
console.log('copy', srcFilename, '->', dstFilename); | ||
const src = await fsPromise.readFile(srcFilename); | ||
const dst = transformFn(src, srcFilename, dstFilename); | ||
await fsPromise.writeFile(dstFilename, dst); | ||
} | ||
|
||
chokidar.watch('.', { | ||
ignored: [ | ||
'.git', | ||
'node_modules', | ||
'build', | ||
'out', | ||
'src', | ||
'dist', | ||
'**/.*', | ||
], | ||
}).on('all', (event, path) => { | ||
switch (event) { | ||
case 'add': | ||
case 'change': | ||
copyFile(path); | ||
break; | ||
case 'ready': | ||
if (!watch) { | ||
resolve(); | ||
} | ||
break; | ||
} | ||
}); | ||
}); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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