Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 84c7411

Browse files
committed
chore: update error messages for interop tests
1 parent f926dd8 commit 84c7411

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

src/cli/mkdir.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ module.exports = {
2929
flush: {
3030
alias: 'f',
3131
type: 'boolean',
32+
default: true,
3233
coerce: asBoolean,
33-
describe: 'Weird undocumented option'
34+
describe: 'Flush the changes to disk immediately'
3435
}
3536
},
3637

src/core/cp.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = (ipfs) => {
5858
return copyToDirectory(ipfs, sources, destination, options, callback)
5959
}
6060

61-
callback(new Error('Error: directory already has entry by that name'))
61+
callback(new Error('directory already has entry by that name'))
6262
})
6363
}
6464
}
@@ -70,7 +70,7 @@ const copyToFile = (ipfs, source, destination, options, callback) => {
7070
(next) => stat(ipfs)(source.path, options, next),
7171
(next) => stat(ipfs)(destination.path, options, (error) => {
7272
if (!error) {
73-
return next(new Error('Error: directory already has entry by that name'))
73+
return next(new Error('directory already has entry by that name'))
7474
}
7575

7676
next()
@@ -125,7 +125,7 @@ const copyToDirectory = (ipfs, sources, destination, options, callback) => {
125125
return (cb) => {
126126
stat(ipfs)(`${destination.path}/${source.name}`, options, (error) => {
127127
if (!error) {
128-
return cb(new Error('Error: directory already has entry by that name'))
128+
return cb(new Error('directory already has entry by that name'))
129129
}
130130

131131
cb()

src/core/mkdir.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = (ipfs) => {
3333
path = path.trim()
3434

3535
if (path === FILE_SEPARATOR) {
36-
return callback(options.parents ? null : new Error(`Error: cannot create directory '${FILE_SEPARATOR}': Already exists`))
36+
return callback(options.parents ? null : new Error(`cannot create directory '${FILE_SEPARATOR}': Already exists`))
3737
}
3838

3939
log(`Creating ${path}`)
@@ -45,7 +45,7 @@ module.exports = (ipfs) => {
4545
createLastComponent: false
4646
}, (error) => {
4747
if (!error) {
48-
log(`${path} already existed`)
48+
log(`${path} already exists`)
4949
return cb(new Error('file already exists'))
5050
}
5151

@@ -65,7 +65,7 @@ module.exports = (ipfs) => {
6565
(result, cb) => updateTree(ipfs, result, cb),
6666
(newRoot, next) => updateMfsRoot(ipfs, newRoot.node.multihash, next)
6767
], (error) => {
68-
if (error && error.message === 'Already exists' && options.parents) {
68+
if (error && error.message.includes('file already exists') && options.parents) {
6969
// when the directory already exists and we are creating intermediate
7070
// directories, do not error out (consistent with mkdir -p)
7171
error = null

src/core/read-pull-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = (ipfs) => {
3535
const meta = UnixFs.unmarshal(node.data)
3636

3737
if (meta.type !== 'file') {
38-
return done(new Error(`Error: ${path} was not a file`))
38+
return done(new Error(`${path} was not a file`))
3939
}
4040

4141
waterfall([

test/mkdir.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ describe('mkdir', function () {
8686
})
8787
})
8888

89+
it('does not error when creating a directory that already exists and parents is true', () => {
90+
const path = '/qux/quux/quuux'
91+
92+
return mfs.mkdir(path, {
93+
parents: true
94+
})
95+
.then(() => mfs.mkdir(path, {
96+
parents: true
97+
}))
98+
})
99+
89100
it('creates a nested directory when -p is true', function () {
90101
const path = '/foo/bar/baz'
91102

0 commit comments

Comments
 (0)