Skip to content

Commit

Permalink
fix: make --no-wrap work as advertised.
Browse files Browse the repository at this point in the history
Fix and test handling of wrap option to w3 up.

| flag         | result      |
|--------------|-------------|
| undefined    | wrap: true  |
| --wrap       | wrap: true  |
| --wrap true  | wrap: true  |
| --wrap=true  | wrap: true  |
| --wrap false | wrap: false |
| --wrap=false | wrap: false |
| --no-wrap    | wrap: false |

License: MIT
Signed-off-by: Oli Evans <[email protected]>
  • Loading branch information
olizilla committed Jan 17, 2024
1 parent 56793f0 commit b0144cc
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ cli
.command('up <file>')
.alias('upload', 'put')
.describe('Store a file(s) to the service and register an upload.')
.option('--no-wrap', "Don't wrap input files with a directory.", false)
.option('-H, --hidden', 'Include paths that start with ".".')
.option('-c, --car', 'File is a CAR file.', false)
.option('--wrap', "Wrap single input file in a directory. Has no effect on directory or CAR uploads. Pass --no-wrap to disable.", true)
.option('--json', 'Format as newline delimited JSON')
.option('--verbose', 'Output more details.')
.option(
Expand Down
64 changes: 64 additions & 0 deletions test/bin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,70 @@ export const testW3Up = {
assert.match(up.error, /Stored 1 file/)
}),

'w3 up --no-wrap': test(async (assert, context) => {
const email = '[email protected]'
await login(context, { email })
await selectPlan(context, { email })

const create = await w3
.args([
'space',
'create',
'home',
'--no-recovery',
'--no-account',
'--customer',
email,
])
.env(context.env.alice)
.join()

assert.ok(create.status.success())

const up = await w3
.args(['up', 'test/fixtures/pinpie.jpg', '--no-wrap'])
.env(context.env.alice)
.join()

assert.match(
up.output,
/bafkreiajkbmpugz75eg2tmocmp3e33sg5kuyq2amzngslahgn6ltmqxxfa/
)
assert.match(up.error, /Stored 1 file/)
}),

'only w3 up --wrap false': test(async (assert, context) => {
const email = '[email protected]'
await login(context, { email })
await selectPlan(context, { email })

const create = await w3
.args([
'space',
'create',
'home',
'--no-recovery',
'--no-account',
'--customer',
email,
])
.env(context.env.alice)
.join()

assert.ok(create.status.success())

const up = await w3
.args(['up', 'test/fixtures/pinpie.jpg', '--no-wrap'])
.env(context.env.alice)
.join()

assert.match(
up.output,
/bafkreiajkbmpugz75eg2tmocmp3e33sg5kuyq2amzngslahgn6ltmqxxfa/
)
assert.match(up.error, /Stored 1 file/)
}),

'w3 up --car': test(async (assert, context) => {
const email = '[email protected]'
await login(context, { email })
Expand Down

0 comments on commit b0144cc

Please sign in to comment.