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);

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.'
);
}

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