@posthog/core 1.5.0 → 1.5.2

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.
@@ -1,2 +1,3 @@
1
1
  export * from './spawn-local';
2
+ export { resolveBinaryPath } from './utils';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/process/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/process/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA"}
@@ -2,6 +2,9 @@
2
2
  var __webpack_modules__ = {
3
3
  "./spawn-local": function(module) {
4
4
  module.exports = require("./spawn-local.js");
5
+ },
6
+ "./utils?198b": function(module) {
7
+ module.exports = require("./utils.js");
5
8
  }
6
9
  };
7
10
  var __webpack_module_cache__ = {};
@@ -47,14 +50,24 @@ function __webpack_require__(moduleId) {
47
50
  var __webpack_exports__ = {};
48
51
  (()=>{
49
52
  __webpack_require__.r(__webpack_exports__);
53
+ __webpack_require__.d(__webpack_exports__, {
54
+ resolveBinaryPath: ()=>_utils__WEBPACK_IMPORTED_MODULE_1__.resolveBinaryPath
55
+ });
50
56
  var _spawn_local__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./spawn-local");
51
57
  var __WEBPACK_REEXPORT_OBJECT__ = {};
52
- for(var __WEBPACK_IMPORT_KEY__ in _spawn_local__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
58
+ for(var __WEBPACK_IMPORT_KEY__ in _spawn_local__WEBPACK_IMPORTED_MODULE_0__)if ([
59
+ "resolveBinaryPath",
60
+ "default"
61
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
53
62
  return _spawn_local__WEBPACK_IMPORTED_MODULE_0__[key];
54
63
  }).bind(0, __WEBPACK_IMPORT_KEY__);
55
64
  __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
65
+ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./utils?198b");
56
66
  })();
57
- for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
67
+ exports.resolveBinaryPath = __webpack_exports__.resolveBinaryPath;
68
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
69
+ "resolveBinaryPath"
70
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
58
71
  Object.defineProperty(exports, '__esModule', {
59
72
  value: true
60
73
  });
@@ -1 +1,3 @@
1
+ import { resolveBinaryPath } from "./utils.mjs";
1
2
  export * from "./spawn-local.mjs";
3
+ export { resolveBinaryPath };
@@ -1,8 +1,6 @@
1
- export declare function spawnLocal(binaryName: string, args: string[], options: {
1
+ export declare function spawnLocal(executable: string, args: string[], options: {
2
2
  env: NodeJS.ProcessEnv;
3
3
  stdio: 'inherit' | 'ignore';
4
- resolveFrom: string;
5
4
  cwd: string;
6
- onBinaryFound: (binaryLocation: string) => void;
7
5
  }): Promise<void>;
8
6
  //# sourceMappingURL=spawn-local.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spawn-local.d.ts","sourceRoot":"","sources":["../../src/process/spawn-local.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;IACtB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAA;IAE3B,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAA;CAChD,GACA,OAAO,CAAC,IAAI,CAAC,CAgCf"}
1
+ {"version":3,"file":"spawn-local.d.ts","sourceRoot":"","sources":["../../src/process/spawn-local.ts"],"names":[],"mappings":"AAEA,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;IACtB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC3B,GAAG,EAAE,MAAM,CAAA;CACZ,GACA,OAAO,CAAC,IAAI,CAAC,CAoBf"}
@@ -26,22 +26,12 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  spawnLocal: ()=>spawnLocal
28
28
  });
29
- const external_node_child_process_namespaceObject = require("node:child_process");
30
- const external_utils_js_namespaceObject = require("./utils.js");
31
- async function spawnLocal(binaryName, args, options) {
32
- let binaryLocation;
33
- try {
34
- binaryLocation = (0, external_utils_js_namespaceObject.resolveBinaryPath)(options.env.PATH ?? '', options.resolveFrom, binaryName);
35
- options.onBinaryFound(binaryLocation);
36
- } catch (e) {
37
- console.error(e);
38
- throw new Error(`Binary ${binaryName} not found. Make sure postinstall script was allowed if it installs the binary`);
39
- }
40
- const child = (0, external_node_child_process_namespaceObject.spawn)(binaryLocation, [
29
+ const external_cross_spawn_namespaceObject = require("cross-spawn");
30
+ async function spawnLocal(executable, args, options) {
31
+ const child = (0, external_cross_spawn_namespaceObject.spawn)(executable, [
41
32
  ...args
42
33
  ], {
43
- shell: true,
44
- stdio: options?.stdio ?? 'inherit',
34
+ stdio: options.stdio ?? 'inherit',
45
35
  env: options.env,
46
36
  cwd: options.cwd
47
37
  });
@@ -1,19 +1,9 @@
1
- import { spawn } from "node:child_process";
2
- import { resolveBinaryPath } from "./utils.mjs";
3
- async function spawnLocal(binaryName, args, options) {
4
- let binaryLocation;
5
- try {
6
- binaryLocation = resolveBinaryPath(options.env.PATH ?? '', options.resolveFrom, binaryName);
7
- options.onBinaryFound(binaryLocation);
8
- } catch (e) {
9
- console.error(e);
10
- throw new Error(`Binary ${binaryName} not found. Make sure postinstall script was allowed if it installs the binary`);
11
- }
12
- const child = spawn(binaryLocation, [
1
+ import { spawn } from "cross-spawn";
2
+ async function spawnLocal(executable, args, options) {
3
+ const child = spawn(executable, [
13
4
  ...args
14
5
  ], {
15
- shell: true,
16
- stdio: options?.stdio ?? 'inherit',
6
+ stdio: options.stdio ?? 'inherit',
17
7
  env: options.env,
18
8
  cwd: options.cwd
19
9
  });
@@ -1,3 +1,6 @@
1
1
  export declare const buildLocalBinaryPaths: (cwd: string) => string[];
2
- export declare function resolveBinaryPath(envPath: string, cwd: string, binName: string): string;
2
+ export declare function resolveBinaryPath(binName: string, options: {
3
+ path: string;
4
+ cwd: string;
5
+ }): string;
3
6
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/process/utils.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,MAAM,EAKzD,CAAA;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAWvF"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/process/utils.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,MAAM,EAKzD,CAAA;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAA;IAEZ,GAAG,EAAE,MAAM,CAAA;CACZ,GACA,MAAM,CAWR"}
@@ -55,9 +55,9 @@ const buildLocalBinaryPaths = (cwd)=>{
55
55
  const localPaths = getLocalPaths(external_node_path_default().resolve(cwd)).map((localPath)=>external_node_path_default().join(localPath, 'node_modules/.bin'));
56
56
  return localPaths;
57
57
  };
58
- function resolveBinaryPath(envPath, cwd, binName) {
59
- const envLocations = envPath.split(external_node_path_default().delimiter);
60
- const localLocations = buildLocalBinaryPaths(cwd);
58
+ function resolveBinaryPath(binName, options) {
59
+ const envLocations = options.path.split(external_node_path_default().delimiter);
60
+ const localLocations = buildLocalBinaryPaths(options.cwd);
61
61
  const directories = [
62
62
  ...new Set([
63
63
  ...localLocations,
@@ -15,9 +15,9 @@ const buildLocalBinaryPaths = (cwd)=>{
15
15
  const localPaths = getLocalPaths(node_path.resolve(cwd)).map((localPath)=>node_path.join(localPath, 'node_modules/.bin'));
16
16
  return localPaths;
17
17
  };
18
- function resolveBinaryPath(envPath, cwd, binName) {
19
- const envLocations = envPath.split(node_path.delimiter);
20
- const localLocations = buildLocalBinaryPaths(cwd);
18
+ function resolveBinaryPath(binName, options) {
19
+ const envLocations = options.path.split(node_path.delimiter);
20
+ const localLocations = buildLocalBinaryPaths(options.cwd);
21
21
  const directories = [
22
22
  ...new Set([
23
23
  ...localLocations,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/core",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -49,9 +49,13 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@rslib/core": "^0.10.5",
52
+ "@types/cross-spawn": "^6.0.6",
52
53
  "jest": "^29.7.0",
53
54
  "@posthog-tooling/tsconfig-base": "1.0.0"
54
55
  },
56
+ "dependencies": {
57
+ "cross-spawn": "^7.0.6"
58
+ },
55
59
  "scripts": {
56
60
  "clean": "rimraf dist",
57
61
  "lint": "eslint src",
@@ -1 +1,2 @@
1
1
  export * from './spawn-local'
2
+ export { resolveBinaryPath } from './utils'
@@ -1,32 +1,16 @@
1
- import { spawn } from 'node:child_process'
2
- import { resolveBinaryPath } from './utils'
1
+ import { spawn } from 'cross-spawn'
3
2
 
4
3
  export async function spawnLocal(
5
- binaryName: string,
4
+ executable: string,
6
5
  args: string[],
7
6
  options: {
8
7
  env: NodeJS.ProcessEnv
9
8
  stdio: 'inherit' | 'ignore'
10
- // We start traversing the file system tree from this directory and we go up until we find the binary
11
- resolveFrom: string
12
9
  cwd: string
13
- onBinaryFound: (binaryLocation: string) => void
14
10
  }
15
11
  ): Promise<void> {
16
- let binaryLocation
17
- try {
18
- binaryLocation = resolveBinaryPath(options.env.PATH ?? '', options.resolveFrom, binaryName)
19
- options.onBinaryFound(binaryLocation)
20
- } catch (e) {
21
- console.error(e)
22
- throw new Error(
23
- `Binary ${binaryName} not found. Make sure postinstall script was allowed if it installs the binary`
24
- )
25
- }
26
-
27
- const child = spawn(binaryLocation, [...args], {
28
- shell: true,
29
- stdio: options?.stdio ?? 'inherit',
12
+ const child = spawn(executable, [...args], {
13
+ stdio: options.stdio ?? 'inherit',
30
14
  env: options.env,
31
15
  cwd: options.cwd,
32
16
  })
@@ -27,9 +27,16 @@ export const buildLocalBinaryPaths = (cwd: string): string[] => {
27
27
  return localPaths
28
28
  }
29
29
 
30
- export function resolveBinaryPath(envPath: string, cwd: string, binName: string): string {
31
- const envLocations = envPath.split(path.delimiter)
32
- const localLocations = buildLocalBinaryPaths(cwd)
30
+ export function resolveBinaryPath(
31
+ binName: string,
32
+ options: {
33
+ path: string
34
+ // We start traversing the file system tree from this directory and we go up until we find the binary
35
+ cwd: string
36
+ }
37
+ ): string {
38
+ const envLocations = options.path.split(path.delimiter)
39
+ const localLocations = buildLocalBinaryPaths(options.cwd)
33
40
  const directories = [...new Set([...localLocations, ...envLocations])]
34
41
  for (const directory of directories) {
35
42
  const binaryPath = path.join(directory, binName)