Skip to content

Commit

Permalink
fix(version): Node14, import from "fs" instead of "node:fs", fixes #260
Browse files Browse the repository at this point in the history
… (#261)
  • Loading branch information
ghiscoding committed Jul 20, 2022
1 parent ef25f6b commit 5e420fd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Expand Up @@ -5,7 +5,7 @@ jest.mock('@lerna-lite/core', () => ({
import path from 'path';
import fs from 'fs-extra';
import core, { Package } from '@lerna-lite/core';
import nodeFs from 'node:fs';
import nodeFs from 'fs';
import npmlog from 'npmlog';

// mocked or stubbed modules
Expand Down
2 changes: 1 addition & 1 deletion packages/version/src/__tests__/version-bump.spec.ts
@@ -1,4 +1,4 @@
const nodeFs = require('node:fs');
import nodeFs from 'fs';
jest.spyOn(nodeFs, 'renameSync');

// local modules _must_ be explicitly mocked
Expand Down
@@ -1,4 +1,4 @@
const nodeFs = require('node:fs');
import nodeFs from 'fs';
jest.spyOn(nodeFs, 'renameSync');

// local modules _must_ be explicitly mocked
Expand Down
6 changes: 3 additions & 3 deletions packages/version/src/lib/update-lockfile-version.ts
@@ -1,7 +1,7 @@
import log from 'npmlog';
import path from 'path';
import loadJsonFile from 'load-json-file';
import { promises as fsPromises, renameSync } from 'node:fs';
import fs from 'fs';
import os from 'os';
import semver from 'semver';
import writeJsonFile from 'write-json-file';
Expand Down Expand Up @@ -168,7 +168,7 @@ export async function runInstallLockFileOnly(

// 2. rename "npm-shrinkwrap.json" back to "package-lock.json"
log.verbose('lock', `renaming "npm-shrinkwrap.json" file back to "package-lock.json"`);
renameSync('npm-shrinkwrap.json', 'package-lock.json');
fs.renameSync('npm-shrinkwrap.json', 'package-lock.json');
}

outputLockfileName = inputLockfileName;
Expand All @@ -195,7 +195,7 @@ export async function runInstallLockFileOnly(
*/
export async function validateFileExists(filePath: string) {
try {
await fsPromises.access(filePath);
await fs.promises.access(filePath);
return true;
} catch {
return false;
Expand Down

0 comments on commit 5e420fd

Please sign in to comment.