@witchcraft/nuxt-electron 0.0.4 → 0.0.6
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/dist/module.d.mts
CHANGED
|
@@ -29,15 +29,15 @@ interface ModuleOptions {
|
|
|
29
29
|
/** Extra cli arguments to launch electron with in dev mode */
|
|
30
30
|
extraCliArgs: string[];
|
|
31
31
|
/**
|
|
32
|
-
* If set, adds `--user-data-dir ${devUserDataDir}` to the cli arguments in development mode.
|
|
32
|
+
* If set, adds `--dev-user-data-dir ${devUserDataDir}` to the cli arguments in development mode.
|
|
33
33
|
*
|
|
34
|
-
* You will then need to parse this in main.ts, a `useDevDataDir` function is provided for this. This does not do any advanced parsing, just takes the next argument after `--user-data-dir` so the path must not contain spaces.
|
|
34
|
+
* You will then need to parse this in main.ts, a `useDevDataDir` function is provided for this. This does not do any advanced parsing, just takes the next argument after `--dev-user-data-dir` so the path must not contain spaces.
|
|
35
35
|
* ```ts
|
|
36
36
|
* const userDataDir = useDevDataDir() ?? app.getPath("userData")
|
|
37
37
|
*
|
|
38
38
|
* @default "~~/.user-data-dir"
|
|
39
39
|
*/
|
|
40
|
-
devUserDataDir: string;
|
|
40
|
+
devUserDataDir: string | null;
|
|
41
41
|
/**
|
|
42
42
|
* The script to run to build/pack the electron app.
|
|
43
43
|
*
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -36,7 +36,7 @@ const module = defineNuxtModule({
|
|
|
36
36
|
srcDir: "~~/app-electron",
|
|
37
37
|
electronBuildDir: "~~/.dist/electron",
|
|
38
38
|
nonElectronNuxtBuildDir: "~~/.dist/web/.output",
|
|
39
|
-
devUserDataDir:
|
|
39
|
+
devUserDataDir: void 0,
|
|
40
40
|
electronRoute: "/app",
|
|
41
41
|
autoOpen: process.env.AUTO_OPEN?.includes("electron"),
|
|
42
42
|
electronBuildPackScript: "npm run build:electron:pack",
|
|
@@ -56,6 +56,9 @@ const module = defineNuxtModule({
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
async setup(options, nuxt) {
|
|
59
|
+
if (options.devUserDataDir === void 0) {
|
|
60
|
+
options.devUserDataDir = "~~/.user-data-dir";
|
|
61
|
+
}
|
|
59
62
|
if (!options.enable) {
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export function useDevDataDir() {
|
|
2
2
|
if (import.meta.dev) {
|
|
3
|
-
const index = process.argv.findIndex((arg) => arg.startsWith("--user-data-dir")) + 1;
|
|
3
|
+
const index = process.argv.findIndex((arg) => arg.startsWith("--dev-user-data-dir")) + 1;
|
|
4
4
|
if (index === -1) return void 0;
|
|
5
|
-
return process.argv[index
|
|
5
|
+
return process.argv[index];
|
|
6
6
|
}
|
|
7
7
|
return void 0;
|
|
8
8
|
}
|
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -65,15 +65,15 @@ export interface ModuleOptions {
|
|
|
65
65
|
/** Extra cli arguments to launch electron with in dev mode */
|
|
66
66
|
extraCliArgs: string[]
|
|
67
67
|
/**
|
|
68
|
-
* If set, adds `--user-data-dir ${devUserDataDir}` to the cli arguments in development mode.
|
|
68
|
+
* If set, adds `--dev-user-data-dir ${devUserDataDir}` to the cli arguments in development mode.
|
|
69
69
|
*
|
|
70
|
-
* You will then need to parse this in main.ts, a `useDevDataDir` function is provided for this. This does not do any advanced parsing, just takes the next argument after `--user-data-dir` so the path must not contain spaces.
|
|
70
|
+
* You will then need to parse this in main.ts, a `useDevDataDir` function is provided for this. This does not do any advanced parsing, just takes the next argument after `--dev-user-data-dir` so the path must not contain spaces.
|
|
71
71
|
* ```ts
|
|
72
72
|
* const userDataDir = useDevDataDir() ?? app.getPath("userData")
|
|
73
73
|
*
|
|
74
74
|
* @default "~~/.user-data-dir"
|
|
75
75
|
*/
|
|
76
|
-
devUserDataDir: string
|
|
76
|
+
devUserDataDir: string | null
|
|
77
77
|
/**
|
|
78
78
|
* The script to run to build/pack the electron app.
|
|
79
79
|
*
|
|
@@ -159,7 +159,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
159
159
|
srcDir: "~~/app-electron",
|
|
160
160
|
electronBuildDir: "~~/.dist/electron",
|
|
161
161
|
nonElectronNuxtBuildDir: "~~/.dist/web/.output",
|
|
162
|
-
devUserDataDir:
|
|
162
|
+
devUserDataDir: undefined,
|
|
163
163
|
electronRoute: "/app",
|
|
164
164
|
autoOpen: process.env.AUTO_OPEN?.includes("electron"),
|
|
165
165
|
electronBuildPackScript: "npm run build:electron:pack",
|
|
@@ -179,6 +179,11 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
async setup(options, nuxt) {
|
|
182
|
+
// if the user explicitly sets it to null we want it to stay null
|
|
183
|
+
if (options.devUserDataDir === undefined) {
|
|
184
|
+
options.devUserDataDir = "~~/.user-data-dir"
|
|
185
|
+
}
|
|
186
|
+
|
|
182
187
|
if (!options.enable) { return }
|
|
183
188
|
const moduleName = "@witchcraft/nuxt-electron"
|
|
184
189
|
const logger = useLogger(moduleName)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export function useDevDataDir(): string | undefined {
|
|
2
2
|
if (import.meta.dev) {
|
|
3
|
-
const index = process.argv.findIndex(arg => arg.startsWith("--user-data-dir")) + 1
|
|
3
|
+
const index = process.argv.findIndex(arg => arg.startsWith("--dev-user-data-dir")) + 1
|
|
4
4
|
if (index === -1) return undefined
|
|
5
|
-
return process.argv[index
|
|
5
|
+
return process.argv[index]
|
|
6
6
|
}
|
|
7
7
|
return undefined
|
|
8
8
|
}
|