Skip to content

Commit

Permalink
run git add --renormalize on the generated reh-web/package.json file (
Browse files Browse the repository at this point in the history
#4764)

This should finally actually legitimately resolve the CRLF issue on
Windows.

### QA Notes

Running `yarn` on Windows should no longer create the extra task of
having to stage the generated reh-web package.json file just to get rid
of "invisible" EOL changes.

Co-authored-by: sharon wang <25834218+sharon-wang@users.noreply.github.com>
  • Loading branch information
sharon-wang and sharon-wang authored Sep 20, 2024
1 parent fc5c9f2 commit 7f99658
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions build/npm/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ function generateRehWebPackageJson() {
// `build` a while before `remote/reh-web` due to the array order of `dirs`).
const mergeJson = require('gulp-merge-json');

const remoteDir = path.join(__dirname, '..', '..', 'remote');
const packageJsonDirPath = path.join(remoteDir, 'reh-web');

// If both package.json files contain the same dependency, the one from remote/web will be used
// because it is the last one in the stream.
gulp.src([
path.join(__dirname, '..', '..', 'remote', 'package.json'),
path.join(__dirname, '..', '..', 'remote', 'web', 'package.json'),
path.join(remoteDir, 'package.json'),
path.join(remoteDir, 'web', 'package.json'),
])
// Merge the package.json files
.pipe(
Expand All @@ -109,7 +112,12 @@ function generateRehWebPackageJson() {
})
)
// Write the merged package.json file to remote/reh-web
.pipe(gulp.dest(path.join(__dirname, '..', '..', 'remote', 'reh-web')));
.pipe(gulp.dest(packageJsonDirPath))
// `git add` the files in remote/reh-web so that line normalization is handled on Windows
.on('end', () => {
const packageJsonPath = path.join(packageJsonDirPath, 'package.json');
cp.execSync(`git add --renormalize ${packageJsonPath}`);
});
}
// --- End Positron ---

Expand Down Expand Up @@ -147,7 +155,7 @@ for (let dir of dirs) {
const isRehWebDir = /^(.build\/distro\/npm\/)?remote\/reh-web$/.test(dir);

if (/^(.build\/distro\/npm\/)?remote$/.test(dir) || isRehWebDir) {
// --- End Positron ---
// --- End Positron ---
// node modules used by vscode server
const env = { ...process.env };
if (process.env['VSCODE_REMOTE_CC']) {
Expand Down

0 comments on commit 7f99658

Please sign in to comment.