mac-helper 0.3.0 → 0.3.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/lib/dialog.js +12 -6
- package/package.json +1 -1
- package/src/dialog.ts +13 -8
package/lib/dialog.js
CHANGED
|
@@ -8,12 +8,18 @@ exports.dialog = {
|
|
|
8
8
|
chooseMultipleFromList,
|
|
9
9
|
};
|
|
10
10
|
async function prompt(label, defaultValue = '') {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
// if cancel dialog, will throw error
|
|
12
|
+
try {
|
|
13
|
+
return ((await (0, run_1.run)((label) => {
|
|
14
|
+
const app = Application.currentApplication();
|
|
15
|
+
app.includeStandardAdditions = true;
|
|
16
|
+
const response = app.displayDialog(label, { defaultAnswer: '' });
|
|
17
|
+
return response.textReturned;
|
|
18
|
+
}, label)) || defaultValue);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return defaultValue;
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
24
|
async function runOnCurrentApp(method, ...args) {
|
|
19
25
|
return await (0, run_1.run)((method, ...args) => {
|
package/package.json
CHANGED
package/src/dialog.ts
CHANGED
|
@@ -8,14 +8,19 @@ export const dialog = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async function prompt(label: string, defaultValue = ''): Promise<string> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
// if cancel dialog, will throw error
|
|
12
|
+
try {
|
|
13
|
+
return (
|
|
14
|
+
(await run((label) => {
|
|
15
|
+
const app = Application.currentApplication()
|
|
16
|
+
app.includeStandardAdditions = true
|
|
17
|
+
const response = app.displayDialog(label, { defaultAnswer: '' })
|
|
18
|
+
return response.textReturned
|
|
19
|
+
}, label)) || defaultValue
|
|
20
|
+
)
|
|
21
|
+
} catch {
|
|
22
|
+
return defaultValue
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
type AppMethod = 'chooseFromList'
|