Skip to content

Side effect when mocking process.getuid() under Windows #809

@aleen42

Description

@aleen42

Recently I have found that when I imported memfs/lib/process.js and used gulp to copy a directory with a subdirectory, I got an error Error: EPERM: operation not permitted, futime.

dest
test
│   index.js
└───sub
    │   index.js

Here is the snippet to show how to reproduce the problem:

// test/index.js
const path = require('path');
const gulp = require('gulp');

// require('memfs/lib/process.js');
process.getuid = process.getuid || (() => 0);
gulp.src(['**/*']).pipe(gulp.dest(path.resolve(__dirname, '../dest')))

It seems that it is a mocked uid resulting in side effects when trying to futime.

The temporary workaround is to revert it within the current process:

require('memfs');
process.platform === 'win32' && delete process.getuid;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions