Skip to content

Commit

Permalink
Merge pull request #122 from bigbite/fix/node-20-compatiblity
Browse files Browse the repository at this point in the history
Adds Node version 20 compatibility
  • Loading branch information
ampersarnie authored Aug 13, 2024
2 parents 88754ac + 3f960e3 commit 1efebfd
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v20
3 changes: 3 additions & 0 deletions __mocks__/fs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { vol } = require('memfs');

module.exports = vol;
35 changes: 14 additions & 21 deletions __tests__/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
'use strict';
const path = require('path');
const mockFs = require('mock-fs');
const { vol: mockVol } = require('memfs');
const { ufs: mockUfs } = require('unionfs');

jest.mock('fs', () => {
// combine the virtual file system with the real one so we can use both at the same time.
return mockUfs.use(jest.requireActual('fs')).use(mockVol);
});

jest.mock('ora', () => () => ({
start: jest.fn(),
}));

const requiredRealDirs = {
node_modules: mockFs.load(path.resolve(__dirname, '../node_modules')),
src: mockFs.load(path.resolve(__dirname, '../src')),
configs: mockFs.load(path.resolve(__dirname, '../configs')),
};

describe('CLI Build Command', () => {
let originalArgv;
let originalWrite;
Expand Down Expand Up @@ -53,13 +52,12 @@ describe('CLI Build Command', () => {
process.stdout.write = originalWrite;
process.exit = originalExit;

mockFs.restore();
mockVol.reset();
jest.resetAllMocks();
});

it('can read global vars', () => {
mockFs({
...requiredRealDirs,
mockVol.fromNestedJSON({
'src/entrypoints': {
'some-file.js': 'console.log("file content here");',
'empty-dir': {
Expand Down Expand Up @@ -88,8 +86,7 @@ describe('CLI Build Command', () => {
});

it('detects single project mode based on filesystem', () => {
mockFs({
...requiredRealDirs,
mockVol.fromNestedJSON({
'src/entrypoints': {
'some-file.js': 'console.log("file content here");',
'empty-dir': {
Expand All @@ -110,8 +107,7 @@ describe('CLI Build Command', () => {
});

it('detects all projects mode based on filesystem', () => {
mockFs({
...requiredRealDirs,
mockVol.fromNestedJSON({
plugins: {
'my-plugin': {
'package.json': JSON.stringify({
Expand All @@ -135,8 +131,7 @@ describe('CLI Build Command', () => {
});

it('runs specific projects mode when requested', () => {
mockFs({
...requiredRealDirs,
mockVol.fromNestedJSON({
plugins: {
'my-plugin': {
'package.json': JSON.stringify({
Expand Down Expand Up @@ -176,8 +171,7 @@ describe('CLI Build Command', () => {
});

it('runs specific projects mode if some requested projects are not found', () => {
mockFs({
...requiredRealDirs,
mockVol.fromNestedJSON({
plugins: {
'my-plugin': {
'package.json': JSON.stringify({
Expand All @@ -204,8 +198,7 @@ describe('CLI Build Command', () => {
});

it('fails to run specific projects mode if no requested projects can be found', () => {
mockFs({
...requiredRealDirs,
mockVol.fromNestedJSON({
plugins: {
'my-plugin': {
'package.json': JSON.stringify({
Expand Down
Loading

0 comments on commit 1efebfd

Please sign in to comment.