@ffflorian/windows-shortcut-maker 2.5.5 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ This module uses a Windows VBScript file to get native access to the operational
20
20
 
21
21
  ## Installation
22
22
 
23
- ℹ️ This is a hybrid [CommonJS](https://nodejs.org/docs/latest/api/modules.html#modules-commonjs-modules) / [ESM](https://nodejs.org/api/esm.html#introduction) module.
23
+ ℹ️ This is a pure [ESM](https://nodejs.org/api/esm.html#introduction) module.
24
24
 
25
25
  Run `yarn global add @ffflorian/windows-shortcut-maker` or `npm i -g @ffflorian/windows-shortcut-maker`
26
26
 
@@ -1,6 +1,6 @@
1
- import { spawn, spawnSync } from 'child_process';
2
- import fs from 'fs';
3
- import path from 'path';
1
+ import { spawn, spawnSync } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
4
  function mergeOptions(options) {
5
5
  const rawName = path.basename(options.filepath).replace(/(.*)\..*$/, '$1');
6
6
  const defaultOptions = {
package/package.json CHANGED
@@ -5,18 +5,13 @@
5
5
  ],
6
6
  "description": "Create Windows shortcuts using a VBScript.",
7
7
  "devDependencies": {
8
- "rimraf": "5.0.7",
9
- "typescript": "5.5.2"
8
+ "rimraf": "6.0.1",
9
+ "typescript": "5.5.4"
10
10
  },
11
11
  "engines": {
12
12
  "node": ">= 18.0"
13
13
  },
14
- "exports": {
15
- ".": {
16
- "import": "./dist/esm/index.js",
17
- "require": "./dist/cjs/index.js"
18
- }
19
- },
14
+ "exports": "./dist/index.js",
20
15
  "files": [
21
16
  "dist",
22
17
  "scripts"
@@ -31,19 +26,15 @@
31
26
  "url"
32
27
  ],
33
28
  "license": "GPL-3.0",
34
- "main": "dist/cjs/index.js",
35
- "module": "dist/esm/index.js",
29
+ "module": "dist/index.js",
36
30
  "name": "@ffflorian/windows-shortcut-maker",
37
31
  "repository": "https://github.com/ffflorian/node-packages/tree/main/packages/windows-shortcut-maker",
38
32
  "scripts": {
39
- "build": "yarn build:cjs && yarn build:esm && yarn generate:packagejson",
40
- "build:cjs": "tsc -p tsconfig.cjs.json",
41
- "build:esm": "tsc -p tsconfig.json",
33
+ "build": "tsc -p tsconfig.json",
42
34
  "clean": "rimraf dist",
43
- "dist": "yarn clean && yarn build",
44
- "generate:packagejson": "../../bin/generate-hybrid-package-json.sh"
35
+ "dist": "yarn clean && yarn build"
45
36
  },
46
37
  "type": "module",
47
- "version": "2.5.5",
48
- "gitHead": "f7a6a79286e4eb85392b5f2d33942ab166142109"
38
+ "version": "2.6.1",
39
+ "gitHead": "aadf648655ecd0f6bea0c989542a16ff636c71a7"
49
40
  }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,24 +0,0 @@
1
- export interface ShortcutOptions {
2
- /** the absolute path including the name of which file should the module make a shortcut (required). */
3
- filepath: string;
4
- /** create the shortcut even if the original file cannot be found. */
5
- force?: boolean;
6
- /** the arguments passed to the original file when the new shortcut is executed. */
7
- linkArgs?: string;
8
- /** the absolute path in which folder the original file should start executing. */
9
- linkCwd?: string;
10
- /** the description message shown when the cursor stands over the new shortcut without clicking it. */
11
- linkDescription?: string;
12
- /** the folder where to save the link (default is the current user's desktop) */
13
- linkFilepath?: string;
14
- /** the key combination that is going to trigger the new shortcut execution. (e.g. `'ALT+CTRL+F'`) */
15
- linkHotkey?: string;
16
- /** the absolute path to an `.ico` extension image used as the icon for the new shortcut. */
17
- linkIcon?: string;
18
- /** the name given for the new shortcut file which obeys the same name rules as a regular file does. */
19
- linkName?: string;
20
- /** the initial window mode adopted by the original file when executed. (e.g. `3` is maximized, `4` is normal and `7` is minimized) */
21
- linkWindowMode?: number;
22
- }
23
- export declare function makeSync(options: ShortcutOptions | string): void;
24
- export declare function make(options: ShortcutOptions | string): Promise<void>;
package/dist/esm/index.js DELETED
@@ -1,67 +0,0 @@
1
- import { spawn, spawnSync } from 'child_process';
2
- import fs from 'fs';
3
- import path from 'path';
4
- function mergeOptions(options) {
5
- const rawName = path.basename(options.filepath).replace(/(.*)\..*$/, '$1');
6
- const defaultOptions = {
7
- filepath: options.filepath,
8
- force: false,
9
- linkArgs: '',
10
- linkCwd: '',
11
- linkDescription: rawName,
12
- linkFilepath: '',
13
- linkHotkey: '',
14
- linkIcon: options.filepath,
15
- linkName: rawName,
16
- linkWindowMode: 4,
17
- };
18
- return {
19
- ...defaultOptions,
20
- ...options,
21
- };
22
- }
23
- function prepare(options) {
24
- if (typeof options === 'string') {
25
- options = { filepath: options };
26
- }
27
- const checkedOptions = mergeOptions(options);
28
- if (!checkedOptions.force && !fs.existsSync(checkedOptions.filepath)) {
29
- throw new Error(`Specified file path "${checkedOptions.filepath}" does not exist`);
30
- }
31
- if (checkedOptions.linkFilepath && !checkedOptions.force) {
32
- if (!fs.existsSync(checkedOptions.linkFilepath)) {
33
- throw new Error(`Specified link file path "${checkedOptions.linkFilepath}" does not exist`);
34
- }
35
- if (!fs.lstatSync(checkedOptions.linkFilepath).isDirectory()) {
36
- throw new Error(`Specified link file path "${checkedOptions.linkFilepath}" is not a directory`);
37
- }
38
- }
39
- return checkedOptions;
40
- }
41
- function buildArgs(options) {
42
- const scriptPath = path.join(__dirname, '../scripts/createLink.vbs');
43
- return [
44
- scriptPath,
45
- options.filepath,
46
- options.linkFilepath,
47
- options.linkName,
48
- options.linkArgs,
49
- options.linkDescription,
50
- options.linkCwd,
51
- options.linkIcon,
52
- options.linkWindowMode.toString(),
53
- options.linkHotkey,
54
- ];
55
- }
56
- export function makeSync(options) {
57
- const checkedOptions = prepare(options);
58
- spawnSync('wscript', buildArgs(checkedOptions));
59
- }
60
- export function make(options) {
61
- const checkedOptions = prepare(options);
62
- return new Promise((resolve, reject) => {
63
- spawn('wscript', buildArgs(checkedOptions))
64
- .on('error', reject)
65
- .on('exit', () => resolve());
66
- });
67
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
File without changes