Skip to content
Draft
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
38 changes: 38 additions & 0 deletions libraries/rush-lib/src/logic/Autoinstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,44 @@ export class Autoinstaller {
} else {
this._logIfConsoleOutputIsNotRestricted(Colorize.green('Already up to date.'));
}

// Write the last-install.flag file so that a subsequent "rush install-autoinstaller"
// will not perform a redundant install.
await this._createFlagsAsync();
}

private async _createFlagsAsync(): Promise<void> {
const autoinstallerFullPath: string = this.folderFullPath;

// Example: .../common/autoinstallers/my-task/.rush/temp
const lastInstallFlagPath: string = path.join(
autoinstallerFullPath,
RushConstants.projectRushFolderName,
'temp'
);

const packageJsonPath: string = path.join(autoinstallerFullPath, 'package.json');
const packageJson: IPackageJson = JsonFile.load(packageJsonPath);
Comment on lines +284 to +285
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get the package.json contents from the existing PackageJsonEditor rather than re-reading the file.


const lastInstallFlag: LastInstallFlag = new LastInstallFlag(lastInstallFlagPath, {
node: process.versions.node,
packageManager: this._rushConfiguration.packageManager,
packageManagerVersion: this._rushConfiguration.packageManagerToolVersion,
packageJson: packageJson,
rushJsonFolder: this._rushConfiguration.rushJsonFolder
});

// Create file: ../common/autoinstallers/my-task/.rush/temp/last-install.flag
await lastInstallFlag.createAsync();

// Example: ../common/autoinstallers/my-task/node_modules
const nodeModulesFolder: string = `${autoinstallerFullPath}/${RushConstants.nodeModulesFolderName}`;
const flagPath: string = `${nodeModulesFolder}/rush-autoinstaller.flag`;

FileSystem.writeFile(
flagPath,
'If this file is deleted, Rush will assume that the node_modules folder has been cleaned and will reinstall it.'
);
Comment on lines +295 to +305
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iclanton , @octogonz , do either of you know why we have two separate flag files? Seems like a waste of work.

}

private _logIfConsoleOutputIsNotRestricted(message?: string): void {
Expand Down