raszi / node-tmp

Temporary file and directory creator for node.js
MIT License
736 stars 92 forks source link

Creating a 777 folder ended up with a 755 folder #248

Closed gwh-cpnet closed 4 years ago

gwh-cpnet commented 4 years ago

Operating System

NodeJS Version

Tmp Version

TBD: 0.1.0

Expected Behavior

TBD: Create a 777 folder

Experienced Behavior

TBD: Created a 755 folder

import fs from 'fs';
import tmp from 'tmp';
import assert from 'assert';
import tmpPromise from 'tmp-promise';

describe('tmp-promise', () => {
  it('should create a 0o777 tmp dir', async () => {
    const tmpDir = await tmpPromise.dir({ mode: 0o777 });
    const { mode } = await fs.promises.stat(tmpDir.path);
    assert.equal(mode & 0o777, 0o777); // eslint-disable-line no-bitwise
    tmpDir.cleanup();
  });
});

describe('tmp', () => {
  it('should create a 0o777 tmp dir', () => {
    const tmpDir = tmp.dirSync({ mode: 0o777 });
    const { mode } = fs.statSync(tmpDir.name);
    assert.equal(mode & 0o777, 0o777); // eslint-disable-line no-bitwise
    tmpDir.removeCallback();
  });
});

result:

1) tmp-promise
      AssertionError [ERR_ASSERTION]: 493 == 511

2) tmp
      AssertionError [ERR_ASSERTION]: 493 == 511
gwh-cpnet commented 4 years ago

okay, it turns out to be a node and linux issue.

https://github.com/nodejs/node/issues/15092#issuecomment-325994747