Skip to content

Commit e1ecf7a

Browse files
committed
[rush-lib] Add ensureFolderExists to plugin autoinstaller file writes
The read+write pattern introduced in PR microsoft#5678 replaced FileSystem.copyFile() which implicitly created destination folders. The writeFile() calls need ensureFolderExists: true to maintain the same behavior.
1 parent 47be70b commit e1ecf7a

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "Fix AutoinstallerPluginLoader to use ensureFolderExists when writing plugin files",
5+
"type": "patch",
6+
"packageName": "@microsoft/rush-lib"
7+
}
8+
],
9+
"packageName": "@microsoft/rush-lib",
10+
"email": "user@users.noreply.github.com"
11+
}

libraries/rush-lib/src/pluginFramework/PluginLoader/AutoinstallerPluginLoader.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export class AutoinstallerPluginLoader extends PluginLoaderBase<IRushPluginConfi
7373
// Use read+write instead of copy to ensure line endings are normalized
7474
const manifestContent: string = FileSystem.readFile(manifestPath);
7575
FileSystem.writeFile(destinationManifestPath, manifestContent, {
76-
convertLineEndings: NewlineKind.Lf
76+
convertLineEndings: NewlineKind.Lf,
77+
ensureFolderExists: true
7778
});
7879
// Make permission consistent since it will be committed to Git
7980
FileSystem.changePosixModeBits(
@@ -105,7 +106,8 @@ export class AutoinstallerPluginLoader extends PluginLoaderBase<IRushPluginConfi
105106
// Use read+write instead of copy to ensure line endings are normalized
106107
const commandLineContent: string = FileSystem.readFile(commandLineJsonFullFilePath);
107108
FileSystem.writeFile(destinationCommandLineJsonFilePath, commandLineContent, {
108-
convertLineEndings: NewlineKind.Lf
109+
convertLineEndings: NewlineKind.Lf,
110+
ensureFolderExists: true
109111
});
110112
// Make permission consistent since it will be committed to Git
111113
FileSystem.changePosixModeBits(

0 commit comments

Comments
 (0)