Skip to content

Commit

Permalink
fix: no-wrap parameter (#25)
Browse files Browse the repository at this point in the history
fixes #17
  • Loading branch information
Alan Shaw authored Dec 14, 2022
1 parent 66a594b commit 38aa353
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cli
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.')
.option('--no-wrap', 'Don\'t wrap input files with a directory.', false)
.option('-H, --hidden', 'Include paths that start with ".".')
.action(upload)

Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ export async function upload (firstPath, opts) {
const totalSize = files.reduce((total, f) => total + f.size, 0)
spinner.stopAndPersist({ text: `${files.length} file${files.length === 1 ? '' : 's'} (${filesize(totalSize)})` })
spinner.start('Storing')
// @ts-ignore
const root = await client.uploadDirectory(files, {
/** @type {(o?: import('@web3-storage/w3up-client/src/types').UploadOptions) => Promise<import('@web3-storage/w3up-client/src/types').AnyLink>} */
const uploadFn = files.length === 1 && opts['no-wrap']
? client.uploadFile.bind(client, files[0])
: client.uploadDirectory.bind(client, files)
const root = await uploadFn({
onShardStored: ({ cid, size }) => {
totalSent += size
spinner.stopAndPersist({ text: cid.toString() })
Expand Down

0 comments on commit 38aa353

Please sign in to comment.