Skip to content

Commit 61a5fc8

Browse files
authored
Allow custom windows.vbs
1 parent 2e94b29 commit 61a5fc8

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const library = {
139139
makeWindowsShortcut: function (options) {
140140
let success = true;
141141

142-
const vbsScript = this.produceWindowsVBSPath();
142+
const vbsScript = options.windows.VBScriptPath || this.produceWindowsVBSPath();
143143
if (!fs.existsSync(vbsScript)) {
144144
helpers.throwError(options, 'Could not locate required "windows.vbs" file.');
145145
success = false;

src/validation.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ const validation = {
378378
/**
379379
* Ensures the Windows file path is valid and exists.
380380
* Resolves any environment variables to absolute paths.
381-
* If no valide filePath is presented, deleted "windows" object.
381+
* If no valid filePath is presented, deleted "windows" object.
382382
*
383383
* @example
384384
* options = validateWindowsFilePath(options);
@@ -407,6 +407,37 @@ const validation = {
407407

408408
return options;
409409
},
410+
/**
411+
* Ensures the windows.vbs file path is valid and exists.
412+
* Resolves any environment variables to absolute paths.
413+
* If no valid path is presented, use the default.
414+
*
415+
* @example
416+
* options = validateWindowsVBScript(options);
417+
*
418+
* @param {object} options User's options
419+
* @return {object} Validated or mutated user options
420+
*/
421+
validateWindowsVBScriptPath: function (options) {
422+
if (!options.windows) {
423+
return options;
424+
}
425+
426+
options.windows.VBScriptPath = helpers.resolveWindowsEnvironmentVariables(options.windows.VBScriptPath);
427+
428+
if (options.windows.VBScriptPath && !fs.existsSync(options.windows.VBScriptPath)) {
429+
options.windows.VBScriptPath = undefined;
430+
}
431+
432+
if (
433+
!options.windows.VBScriptPath ||
434+
typeof(options.windows.VBScriptPath) !== 'string'
435+
) {
436+
options.windows.VBScriptPath = undefined;
437+
}
438+
439+
return options;
440+
},
410441
/**
411442
* Verifies or defaults the windowMode.
412443
*
@@ -577,6 +608,7 @@ const validation = {
577608
return options;
578609
}
579610

611+
options = this.validateWindowsVBScriptPath(options);
580612
options = this.validateWindowsWindowMode(options);
581613
options = this.validateWindowsIcon(options);
582614
options = this.validateWindowsComment(options);

0 commit comments

Comments
 (0)