Skip to content

Commit 81cd6a8

Browse files
authored
fix(publish): use file name as label when multiple (#179)
1 parent 5190621 commit 81cd6a8

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ Create a [personal access token](https://docs.gitlab.com/ce/user/profile/persona
6969
Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array` of
7070
[globs](https://github.com/isaacs/node-glob#glob-primer) and `Object`s with the following properties:
7171

72-
| Property | Description | Default |
73-
| -------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------ |
74-
| `path` | **Required.** A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload. | - |
75-
| `label` | Short description of the file displayed on the GitLab release. | File name extracted from the `path`. |
72+
| Property | Description | Default |
73+
| -------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------ |
74+
| `path` | **Required.** A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload. | - |
75+
| `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`. |
7676

7777
Each entry in the `assets` `Array` is globbed individually. A [glob](https://github.com/isaacs/node-glob#glob-primer)
7878
can be a `String` (`"dist/**/*.js"` or `"dist/mylib.js"`) or an `Array` of `String`s that will be globbed together

lib/glob-assets.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ module.exports = async ({cwd}, assets) =>
3838
// If asset is an Object with a glob the `path` property that resolve to multiple files,
3939
// Output an Object definition for each file matched and set each one with:
4040
// - `path` of the matched file
41-
// - `name` based on the actual file name (to avoid assets with duplicate `name`)
41+
// - `label` based on the actual file name (to avoid assets with duplicate `label`s)
4242
// - other properties of the original asset definition
43-
return globbed.map(file => ({...asset, path: file, name: basename(file)}));
43+
return globbed.map(file => ({...asset, path: file, label: basename(file)}));
4444
}
4545

4646
// If asset is an Object, output an Object definition with:

test/glob-assets.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ test('Accept glob array with one value for missing files', async t => {
127127
test('Replace name by filename for Object that match multiple files', async t => {
128128
const cwd = tempy.directory();
129129
await copy(fixtures, cwd);
130-
const globbedAssets = await globAssets({cwd}, [{path: '*.txt', name: 'upload_name', label: 'Upload label'}]);
130+
const globbedAssets = await globAssets({cwd}, [{path: '*.txt', label: 'Upload label'}]);
131131

132132
t.deepEqual(
133133
sortAssets(globbedAssets),
134134
sortAssets([
135-
{path: 'upload.txt', name: 'upload.txt', label: 'Upload label'},
136-
{path: 'upload_other.txt', name: 'upload_other.txt', label: 'Upload label'},
135+
{path: 'upload.txt', label: 'upload.txt'},
136+
{path: 'upload_other.txt', label: 'upload_other.txt'},
137137
])
138138
);
139139
});

0 commit comments

Comments
 (0)