New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move: do not create parent directory if it is root #897
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
56be88f
move: do not create parent directory if it is root
manidlou 58f4021
fix move-sync test
manidlou 78d2bfe
move-sync test: remove dest after test is done
manidlou 3050210
remove debug log
manidlou d42f350
remove dest in afterEach
manidlou 060cd87
call done() after test is done
manidlou File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -8,6 +8,8 @@ const assert = require('assert') | |
|
||
/* global afterEach, beforeEach, describe, it */ | ||
|
||
const describeIfWindows = process.platform === 'win32' ? describe : describe.skip | ||
|
||
function createAsyncErrFn (errCode) { | ||
const fn = function (...args) { | ||
fn.callCount++ | ||
|
@@ -63,7 +65,7 @@ describe('+ move()', () => { | |
fs.readFile(dest, 'utf8', (err, contents) => { | ||
const expected = /^sonic the hedgehog\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected), `${contents} match ${expected}`) | ||
assert.ok(contents.match(expected)) | ||
done() | ||
}) | ||
}) | ||
|
@@ -114,7 +116,7 @@ describe('+ move()', () => { | |
fs.readFile(path.join(dest, 'another-folder', 'file3'), 'utf8', (err, contents) => { | ||
const expected = /^knuckles\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected), `${contents} match ${expected}`) | ||
assert.ok(contents.match(expected)) | ||
tearDownMockFs() | ||
done() | ||
}) | ||
|
@@ -132,7 +134,7 @@ describe('+ move()', () => { | |
fs.readFile(dest, 'utf8', (err, contents) => { | ||
const expected = /^sonic the hedgehog\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected), `${contents} match ${expected}`) | ||
assert.ok(contents.match(expected)) | ||
done() | ||
}) | ||
}) | ||
|
@@ -206,7 +208,7 @@ describe('+ move()', () => { | |
fs.readFile(dest, 'utf8', (err, contents) => { | ||
const expected = /^sonic the hedgehog\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected), `${contents} match ${expected}`) | ||
assert.ok(contents.match(expected)) | ||
done() | ||
}) | ||
}) | ||
|
@@ -225,7 +227,7 @@ describe('+ move()', () => { | |
fs.readFile(dest, 'utf8', (err, contents) => { | ||
const expected = /^sonic the hedgehog\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected), `${contents} match ${expected}`) | ||
assert.ok(contents.match(expected)) | ||
tearDownMockFs() | ||
done() | ||
}) | ||
|
@@ -244,7 +246,7 @@ describe('+ move()', () => { | |
fs.readFile(path.join(dest, 'another-file'), 'utf8', (err, contents) => { | ||
const expected = /^tails\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected), `${contents} match ${expected}`) | ||
assert.ok(contents.match(expected)) | ||
done() | ||
}) | ||
}) | ||
|
@@ -263,14 +265,34 @@ describe('+ move()', () => { | |
fs.readFile(path.join(dest, 'another-folder', 'file3'), 'utf8', (err, contents) => { | ||
const expected = /^knuckles\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected), `${contents} match ${expected}`) | ||
assert.ok(contents.match(expected)) | ||
tearDownMockFs() | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
describeIfWindows('> when dest parent is root', () => { | ||
it('should not create parent directory', done => { | ||
const src = path.join(TEST_DIR, 'a-file') | ||
const dest = path.join(path.parse(TEST_DIR).root, 'another-file') | ||
|
||
fse.move(src, dest, err => { | ||
assert.ifError(err) | ||
fs.readFile(dest, 'utf8', (err, contents) => { | ||
const expected = /^sonic the hedgehog\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected)) | ||
// this test is a bit special since | ||
// we're moving to root, so we need to | ||
// manually remove dest after we're done. | ||
fse.remove(dest, done) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('> clobber', () => { | ||
it('should be an alias for overwrite', done => { | ||
const src = path.join(TEST_DIR, 'a-file') | ||
|
@@ -284,7 +306,7 @@ describe('+ move()', () => { | |
fs.readFile(dest, 'utf8', (err, contents) => { | ||
const expected = /^sonic the hedgehog\r?\n$/ | ||
assert.ifError(err) | ||
assert.ok(contents.match(expected), `${contents} match ${expected}`) | ||
assert.ok(contents.match(expected)) | ||
done() | ||
}) | ||
}) | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be in an
afterEach
in thisdescribeIfWindows
block.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! I will update it then.