-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
72 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'sku': patch | ||
--- | ||
|
||
Fix a bug that could occur when running `sku build` or `sku build-ssr` that caused the copying of assets from the `public` folder to the `target` folder to fail |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,46 @@ | ||
const path = require('path'); | ||
const fs = require('fs/promises'); | ||
const exists = require('./exists'); | ||
|
||
/** | ||
* Recursively copy the contents of a directory into another directory | ||
* If the desitnation directory does not already exist, it will be created | ||
* | ||
* @typedef {import('fs').PathLike} PathLike | ||
* @param {string} srcPath The src path of a | ||
* @param {string} destPath A path to a file or directory | ||
*/ | ||
const copyDirContents = async (srcPath, destPath) => { | ||
const srcStat = await fs.stat(srcPath); | ||
if (!srcStat.isDirectory()) { | ||
throw new Error(`Source ${srcPath} is not a directory`); | ||
} | ||
|
||
if (await exists(destPath)) { | ||
const destStat = await fs.stat(destPath); | ||
if (!destStat.isDirectory()) { | ||
throw new Error(`Destination ${destPath} is not a directory`); | ||
} | ||
} else { | ||
await fs.mkdir(destPath); | ||
} | ||
|
||
const srcItems = await fs.readdir(srcPath); | ||
|
||
for (const srcItem of srcItems) { | ||
const srcItemPath = path.resolve(srcPath, srcItem); | ||
const srcItemStat = await fs.stat(srcItemPath); | ||
|
||
const destItemPath = path.resolve(destPath, srcItem); | ||
|
||
if (srcItemStat.isFile()) { | ||
// destItemPath will also be a file path, not a folder | ||
await fs.copyFile(srcItemPath, destItemPath); | ||
} else if (srcItemStat.isDirectory()) { | ||
// recursively copy src item directory contents | ||
await copyDirContents(srcItemPath, destItemPath); | ||
} | ||
} | ||
}; | ||
|
||
module.exports = copyDirContents; |
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