diff --git a/README.md b/README.md index b4dbdd1d..786d2416 100644 --- a/README.md +++ b/README.md @@ -69,10 +69,10 @@ Create a [personal access token](https://docs.gitlab.com/ce/user/profile/persona Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array` of [globs](https://github.com/isaacs/node-glob#glob-primer) and `Object`s with the following properties: -| Property | Description | Default | -| -------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------ | -| `path` | **Required.** A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload. | - | -| `label` | Short description of the file displayed on the GitLab release. | File name extracted from the `path`. | +| Property | Description | Default | +| -------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------ | +| `path` | **Required.** A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload. | - | +| `label` | Short description of the file displayed on the GitLab release. Ignored if `path` matches more than one file.| File name extracted from the `path`. | Each entry in the `assets` `Array` is globbed individually. A [glob](https://github.com/isaacs/node-glob#glob-primer) can be a `String` (`"dist/**/*.js"` or `"dist/mylib.js"`) or an `Array` of `String`s that will be globbed together diff --git a/lib/glob-assets.js b/lib/glob-assets.js index 8b3e7721..2231de7e 100644 --- a/lib/glob-assets.js +++ b/lib/glob-assets.js @@ -38,9 +38,9 @@ module.exports = async ({cwd}, assets) => // If asset is an Object with a glob the `path` property that resolve to multiple files, // Output an Object definition for each file matched and set each one with: // - `path` of the matched file - // - `name` based on the actual file name (to avoid assets with duplicate `name`) + // - `label` based on the actual file name (to avoid assets with duplicate `label`s) // - other properties of the original asset definition - return globbed.map(file => ({...asset, path: file, name: basename(file)})); + return globbed.map(file => ({...asset, path: file, label: basename(file)})); } // If asset is an Object, output an Object definition with: diff --git a/test/glob-assets.test.js b/test/glob-assets.test.js index c6a54972..ac5c8238 100644 --- a/test/glob-assets.test.js +++ b/test/glob-assets.test.js @@ -127,13 +127,13 @@ test('Accept glob array with one value for missing files', async t => { test('Replace name by filename for Object that match multiple files', async t => { const cwd = tempy.directory(); await copy(fixtures, cwd); - const globbedAssets = await globAssets({cwd}, [{path: '*.txt', name: 'upload_name', label: 'Upload label'}]); + const globbedAssets = await globAssets({cwd}, [{path: '*.txt', label: 'Upload label'}]); t.deepEqual( sortAssets(globbedAssets), sortAssets([ - {path: 'upload.txt', name: 'upload.txt', label: 'Upload label'}, - {path: 'upload_other.txt', name: 'upload_other.txt', label: 'Upload label'}, + {path: 'upload.txt', label: 'upload.txt'}, + {path: 'upload_other.txt', label: 'upload_other.txt'}, ]) ); });