aboutsummaryrefslogtreecommitdiff
path: root/test/harness/compatFs.js
blob: 911be46531c02a28e2bb8e746ac1c9ac08648df1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import fs from 'fs';
let fsp = fs.promises;

if (typeof process == 'undefined') {
    globalThis.process = {};
}

let test_dir = process.env && process.env['NJS_TEST_DIR'] || 'build';
test_dir = `${test_dir}/test`;

function has_fs_symbolic_link() {

    let fname = test_dir + '/a';
    let lname = test_dir + '/b';

    try { fs.unlinkSync(fname); fs.unlinkSync(lname); } catch (e) {}

    fs.writeFileSync(fname, fname);

    fname = fs.realpathSync(fname);

    try {
        fs.symlinkSync(fname, lname);
    } catch (e) {
        return false;
    }

    return true;
}