Skip to content

Commit

Permalink
Fix an issue with the 'folderToCopy' option.
Browse files Browse the repository at this point in the history
  • Loading branch information
iclanton committed Dec 11, 2023
1 parent 2c3c3b2 commit c5dcf78
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
10 changes: 10 additions & 0 deletions common/changes/@microsoft/rush/main_2023-12-11-23-29.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix an issue where the contents of a folder set in the `\"folderToCopy\"` field of the `deploy.json` config file would be copied into a subfolder instead of into the root of the deploy folder.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/package-extractor",
"comment": "Fix an issue with the `folderToCopy` option, where the folder contents would be copied into a subfolder instead of into the target folder root.",
"type": "patch"
}
],
"packageName": "@rushstack/package-extractor"
}
17 changes: 6 additions & 11 deletions libraries/package-extractor/src/PackageExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export class PackageExtractor {
mainProjectName,
sourceRootFolder,
targetRootFolder,
folderToCopy: addditionalFolderToCopy,
folderToCopy: additionalFolderToCopy,
linkCreation
} = options;
const { projectConfigurationsByName, foldersToCopy, symlinkAnalyzer } = state;
Expand Down Expand Up @@ -409,19 +409,14 @@ export class PackageExtractor {
}
);

if (addditionalFolderToCopy) {
// Copy the additional folder directly into the root of the target folder by postfixing the
// folder name to the target folder and setting the sourceRootFolder to the root of the
// folderToCopy
const additionalFolderPath: string = path.resolve(sourceRootFolder, addditionalFolderToCopy);
const targetFolderPath: string = path.join(
options.targetRootFolder,
path.basename(additionalFolderPath)
);
if (additionalFolderToCopy) {
// Copy the additional folder directly into the root of the target folder by setting the sourceRootFolder
// to the root of the folderToCopy
const additionalFolderPath: string = path.resolve(sourceRootFolder, additionalFolderToCopy);
const additionalFolderExtractorOptions: IExtractorOptions = {
...options,
sourceRootFolder: additionalFolderPath,
targetRootFolder: targetFolderPath
targetRootFolder: options.targetRootFolder
};
await this._extractFolderAsync(additionalFolderPath, additionalFolderExtractorOptions, state);
}
Expand Down
5 changes: 2 additions & 3 deletions libraries/package-extractor/src/test/PackageExtractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ describe(PackageExtractor.name, () => {
expect(FileSystem.exists(path.join(targetFolder, project1RelativePath, 'src', 'index.js'))).toBe(true);

// Validate project 2 files
const project2FolderName: string = path.basename(project2Path);
expect(FileSystem.exists(path.join(targetFolder, project2FolderName, 'package.json'))).toBe(true);
expect(FileSystem.exists(path.join(targetFolder, project2FolderName, 'src', 'index.js'))).toBe(true);
expect(FileSystem.exists(path.join(targetFolder, 'package.json'))).toBe(true);
expect(FileSystem.exists(path.join(targetFolder, 'src', 'index.js'))).toBe(true);
});
});

0 comments on commit c5dcf78

Please sign in to comment.