Skip to content

Commit 44d4b1f

Browse files
Linux arguments
1 parent c9f613a commit 44d4b1f

6 files changed

Lines changed: 54 additions & 23 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ const shortcutsCreated = createDesktopShortcut({
9999
// OPTIONAL: defaults to false
100100
terminal: false,
101101
// OPTIONAL: defaults to true
102-
chmod: true
102+
chmod: true,
103+
// OPTIONAL
104+
arguments: '--my-argument -f'
103105
},
104106
osx: {
105107
// REQUIRED: Path must exist
@@ -157,6 +159,7 @@ Key | Type | Allowed | Default
157159
`type` | String | `'Application'`, `'Link'`, `'Directory'` | Based on `filePath` | Type of shortcut. Defaults to `'Link'` if `filePath` starts with `'http://'` or `'https://'`. Defaults to `'Directory'` if filePath exists and is a folder. Defaults to Application otherwise.
158160
`terminal` | Boolean | `true`, `false` | `false` | If true, will run in a terminal.
159161
`chmod` | Boolean | `true`, `false` | `true` | If true, will apply a `chmod +x` (755) to the shortcut after creation to allow execution permission.
162+
`arguments` | String | Any string | None | Additional arguments passed in to the end of your target `filePath`
160163

161164

162165
### OSX Settings

package-lock.json

Lines changed: 28 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "create-desktop-shortcuts",
33
"main": "index.js",
4-
"version": "1.3.0",
4+
"version": "1.4.0",
55
"description": "Easy API to create desktop shortcuts with Node",
66
"author": "The Jared Wilcurt",
77
"keywords": [
@@ -26,10 +26,10 @@
2626
},
2727
"devDependencies": {
2828
"babel-eslint": "^10.1.0",
29-
"eslint": "^7.18.0",
29+
"eslint": "^7.20.0",
3030
"eslint-config-tjw-base": "^1.0.0",
3131
"eslint-config-tjw-jest": "^1.0.0",
32-
"eslint-plugin-jsdoc": "^31.3.3",
32+
"eslint-plugin-jsdoc": "^31.6.1",
3333
"fs-extra": "^9.1.0",
3434
"jest": "24.9.0",
3535
"mock-fs": "^4.13.0"

src/library.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const library = {
5353
if (options.linux.icon) {
5454
icon = 'Icon=' + options.linux.icon;
5555
}
56+
if (options.linux.arguments) {
57+
exec = exec + ' ' + options.linux.arguments;
58+
}
5659

5760
// File format details:
5861
// https://wiki.archlinux.org/index.php/Desktop_entries

src/validation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ const validation = {
339339
options = this.defaultBoolean(options, 'linux', 'terminal', false);
340340
options = this.defaultBoolean(options, 'linux', 'chmod', true);
341341
options = this.validateOptionalString(options, 'linux', 'comment');
342+
options = this.validateOptionalString(options, 'linux', 'arguments');
342343

343344
return options;
344345
},

tests/src/library.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,21 @@ describe('library', () => {
147147
'Icon=/home/DUMMY/icon.png'
148148
].join('\n'));
149149
});
150+
151+
test('Arguments', () => {
152+
options.linux.arguments = '-f --version';
153+
154+
expect(library.generateLinuxFileData(options))
155+
.toEqual([
156+
'#!/user/bin/env xdg-open',
157+
'[Desktop Entry]',
158+
'Version=1.0',
159+
'Type=Application',
160+
'Terminal=false',
161+
'Exec=/home/DUMMY/file.ext -f --version',
162+
'Name=file'
163+
].join('\n'));
164+
});
150165
});
151166

152167
describe('makeLinuxShortcut', () => {

0 commit comments

Comments
 (0)