-
Notifications
You must be signed in to change notification settings - Fork 250
/
Copy pathfilesystem-spec.js
43 lines (37 loc) · 1.38 KB
/
filesystem-spec.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
const assert = require('assert');
const fs = require('../lib/wrapped-fs').default;
const path = require('path');
const rimraf = require('rimraf');
const Filesystem = require('../lib/filesystem').Filesystem;
describe('filesystem', function () {
beforeEach(() => {
rimraf.sync(path.join(__dirname, '..', 'tmp'), fs);
});
it('should does not throw an error when the src path includes a symbol link', async () => {
/**
* Directory structure:
* tmp
* ├── private
* │ └── var
* │ ├── app
* │ │ └── file.txt -> ../file.txt
* │ └── file.txt
* └── var -> private/var
*/
const tmpPath = path.join(__dirname, '..', 'tmp');
const privateVarPath = path.join(tmpPath, 'private', 'var');
const varPath = path.join(tmpPath, 'var');
fs.mkdirSync(privateVarPath, { recursive: true });
fs.symlinkSync(path.relative(tmpPath, privateVarPath), varPath);
const originFilePath = path.join(varPath, 'file.txt');
fs.writeFileSync(originFilePath, 'hello world');
const appPath = path.join(varPath, 'app');
fs.mkdirpSync(appPath);
fs.symlinkSync('../file.txt', path.join(appPath, 'file.txt'));
const filesystem = new Filesystem(varPath);
assert.doesNotThrow(() => {
filesystem.insertLink(path.join(appPath, 'file.txt'));
});
});
});