2024-12-12 09:11:58 -03:00
|
|
|
// Flags: --permission --allow-fs-read=* --allow-child-process
|
2023-12-30 13:46:27 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const path = require('path');
|
2025-01-22 14:19:38 -08:00
|
|
|
const { isMainThread } = require('worker_threads');
|
|
|
|
|
|
|
|
if (!isMainThread) {
|
|
|
|
common.skip('This test only works on a main thread');
|
|
|
|
}
|
2023-12-30 13:46:27 +00:00
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const { spawnSync } = require('child_process');
|
|
|
|
|
|
|
|
{
|
|
|
|
// Relative path as CLI args are supported
|
|
|
|
const { status, stdout } = spawnSync(
|
|
|
|
process.execPath,
|
|
|
|
[
|
2024-12-12 09:11:58 -03:00
|
|
|
'--permission',
|
2023-12-30 13:46:27 +00:00
|
|
|
'--allow-fs-read', '*',
|
|
|
|
'--allow-fs-write', path.resolve('../fixtures/permission/deny/regular-file.md'),
|
|
|
|
'-e',
|
|
|
|
`
|
|
|
|
const path = require("path");
|
|
|
|
const absolutePath = path.resolve("../fixtures/permission/deny/regular-file.md");
|
|
|
|
console.log(process.permission.has("fs.write", absolutePath));
|
|
|
|
`,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
const [fsWrite] = stdout.toString().split('\n');
|
|
|
|
assert.strictEqual(fsWrite, 'true');
|
|
|
|
assert.strictEqual(status, 0);
|
|
|
|
}
|