-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kevin Cui <[email protected]> Co-authored-by: Kevin Cui <[email protected]>
- Loading branch information
1 parent
dd18c0c
commit d8111fc
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict' | ||
|
||
const assert = require('assert') | ||
const fs = require('../lib/wrapped-fs') | ||
const path = require('path') | ||
const rimraf = require('rimraf') | ||
|
||
const Filesystem = require('../lib/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')) | ||
}) | ||
}) | ||
}) |