mac-helper 0.1.4 → 0.1.5

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/finder.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getQSpaceSelected = exports.getFinderSelected = exports.getPathFinderSelected = exports.QSpace = exports.Finder = exports.PathFinder = void 0;
4
4
  const run_1 = require("@jxa/run");
5
5
  const url_1 = require("url");
6
+ const app_1 = require("./app");
6
7
  /**
7
8
  * `App` named epxorts
8
9
  */
@@ -34,6 +35,9 @@ exports.QSpace = {
34
35
  * impls
35
36
  */
36
37
  async function getPathFinderSelected() {
38
+ if (!(await (0, app_1.isAppRunning)('Path Finder'))) {
39
+ return [];
40
+ }
37
41
  const filePaths = await (0, run_1.run)(() => {
38
42
  const app = Application('Path Finder');
39
43
  return (app.selection() || []).map((x) => x.posixPath());
@@ -51,6 +55,9 @@ async function getFinderSelected() {
51
55
  }
52
56
  exports.getFinderSelected = getFinderSelected;
53
57
  async function getQSpaceSelected() {
58
+ if (!(await (0, app_1.isAppRunning)('QSpace Pro'))) {
59
+ return [];
60
+ }
54
61
  const urls = await (0, run_1.run)(() => {
55
62
  const app = Application('QSpace Pro');
56
63
  const selection = (app.selectedItems() || []).map((x) => x.urlstr());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mac-helper",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "useful helper for macOS",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/finder.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { run as jxaRun } from '@jxa/run'
2
2
  import { type PathFinder as PathFinderType } from 'jxa-common-used'
3
3
  import { fileURLToPath } from 'url'
4
+ import { isAppRunning } from './app'
4
5
 
5
6
  /**
6
7
  * `App` named epxorts
@@ -35,6 +36,9 @@ export const QSpace = {
35
36
  */
36
37
 
37
38
  export async function getPathFinderSelected() {
39
+ if (!(await isAppRunning('Path Finder'))) {
40
+ return []
41
+ }
38
42
  const filePaths: string[] = await jxaRun(() => {
39
43
  const app = Application<PathFinderType>('Path Finder')
40
44
  return (app.selection() || []).map((x) => x.posixPath())
@@ -66,6 +70,9 @@ export type QSpaceFileItem = {
66
70
  }
67
71
 
68
72
  export async function getQSpaceSelected() {
73
+ if (!(await isAppRunning('QSpace Pro'))) {
74
+ return []
75
+ }
69
76
  const urls: string[] = await jxaRun(() => {
70
77
  const app = Application('QSpace Pro')
71
78
  const selection = (app.selectedItems() || []).map((x: QSpaceFileItem) => x.urlstr())