Skip to content

Commit

Permalink
chore: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
g-chao committed Apr 24, 2024
1 parent 9c3660a commit 9ac16ff
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tests/pnpm-sync-api-test/src/test/pnpmSyncCopy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,22 @@ describe('pnpm-sync-api copy test', () => {
// let get the file info of package.json in destination folder
const oldDestinationPackageJsonStat = fs.statSync(destinationPackageJsonPath);

// now let do some file operations in source folder
// now let's do some file operations in source folder
// create a new file
fs.writeFileSync(path.join(sourcePath, 'dist/index.new.js'), 'console.log("Hello World!")');
// delete a old file
fs.rmSync(path.join(sourcePath, 'dist/index.js'));
// modify a old file
// modify an existing file
const sourcePackageJsonPath = path.join(sourcePath, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(sourcePackageJsonPath).toString());
const newPackageJsonDescription = 'Test description value';
packageJson.description = newPackageJsonDescription;
fs.writeFileSync(sourcePackageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');

// let get the file info of package.json in source folder
// let get the file info of modified package.json in source folder
const sourcePackageJsonStat = fs.statSync(sourcePackageJsonPath);

fs.writeFileSync(sourcePackageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');

// now let run pnpmSyncCopyAsync again
// now let's run pnpmSyncCopyAsync again
await pnpmSyncCopyAsync({
pnpmSyncJsonPath,
getPackageIncludedFiles: PackageExtractor.getPackageIncludedFilesAsync,
Expand All @@ -206,10 +205,10 @@ describe('pnpm-sync-api copy test', () => {
// 1. for file edit operation
// let's read the file info of package.json in destination folder again
const newDestinationPackageJsonStat = fs.statSync(destinationPackageJsonPath);
// the file ino number should not be changed!
// Since it is a hard link, the file inode number should not be changed, still the original inode number!
expect(sourcePackageJsonStat.ino).toBe(newDestinationPackageJsonStat.ino);
expect(sourcePackageJsonStat.ino).toBe(oldDestinationPackageJsonStat.ino);
// the actual content should be the new value
// and, the actual content in destination folder should be the new value
expect(JSON.parse(fs.readFileSync(destinationPackageJsonPath).toString()).description).toBe(
newPackageJsonDescription
);
Expand Down

0 comments on commit 9ac16ff

Please sign in to comment.