Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/core/fs/src/NodeFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export class NodeFS implements FileSystem {
const move = async () => {
if (!failed) {
try {
await fs.promises.rename(tmpFilePath, filePath);
// await fs.promises.rename(tmpFilePath, filePath);
await fs.promises.copyFile(tmpFilePath, filePath);
await fs.promises.unlink(tmpFilePath);
} catch (e) {
// This is adapted from fs-write-stream-atomic. Apparently
// Windows doesn't like renaming when the target already exists.
Expand Down Expand Up @@ -151,7 +153,12 @@ export class NodeFS implements FileSystem {
): Promise<void> {
let tmpFilePath = getTempFilePath(filePath);
await fs.promises.writeFile(tmpFilePath, contents, options);
await fs.promises.rename(tmpFilePath, filePath);
if (process.platform !== 'win32') {
await fs.promises.rename(tmpFilePath, filePath);
} else {
await fs.promises.copyFile(tmpFilePath, filePath);
await fs.promises.unlink(tmpFilePath);
}
}

readFileSync(filePath: FilePath, encoding?: Encoding): any {
Expand Down
7 changes: 6 additions & 1 deletion packages/utils/create-react-app/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ async function run(packagePath: string) {
throw e;
}

await fs.promises.rename(tempPath, packagePath);
if (process.platform !== 'win32') {
await fs.promises.rename(tempPath, packagePath);
} else {
await fs.promises.copyFile(tempPath, packagePath);
await fs.promises.unlink(tempPath);
}

log(
chalk`{green ${emoji.success} Successfully created a new Parcel app at {bold.underline ${packagePath}}.}`,
Expand Down