import-squeeze 0.1.0

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.
Files changed (2) hide show
  1. package/bin.js +59 -0
  2. package/package.json +16 -0
package/bin.js ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const path = require("path");
5
+ const os = require("os");
6
+
7
+ const PLATFORMS = {
8
+ darwin: {
9
+ arm64: "@import-squeeze/darwin-arm64",
10
+ x64: "@import-squeeze/darwin-x64",
11
+ },
12
+ linux: {
13
+ x64: "@import-squeeze/linux-x64",
14
+ },
15
+ win32: {
16
+ x64: "@import-squeeze/win32-x64",
17
+ },
18
+ };
19
+
20
+ function getBinaryPath() {
21
+ const platform = os.platform();
22
+ const arch = os.arch();
23
+
24
+ const platformPackages = PLATFORMS[platform];
25
+ if (!platformPackages) {
26
+ throw new Error(`Unsupported platform: ${platform}`);
27
+ }
28
+
29
+ const packageName = platformPackages[arch];
30
+ if (!packageName) {
31
+ throw new Error(`Unsupported architecture: ${platform}-${arch}`);
32
+ }
33
+
34
+ const binaryName =
35
+ platform === "win32" ? "import-squeeze.exe" : "import-squeeze";
36
+
37
+ try {
38
+ const packageDir = path.dirname(require.resolve(`${packageName}/package.json`));
39
+ return path.join(packageDir, binaryName);
40
+ } catch {
41
+ throw new Error(
42
+ `Could not find binary package ${packageName}. ` +
43
+ `Make sure it's installed (it should be an optionalDependency).`
44
+ );
45
+ }
46
+ }
47
+
48
+ try {
49
+ const binaryPath = getBinaryPath();
50
+ const result = execFileSync(binaryPath, process.argv.slice(2), {
51
+ stdio: "inherit",
52
+ });
53
+ } catch (error) {
54
+ if (error.status !== undefined) {
55
+ process.exit(error.status);
56
+ }
57
+ console.error(error.message);
58
+ process.exit(1);
59
+ }
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "import-squeeze",
3
+ "version": "0.1.0",
4
+ "description": "Fast CLI tool to remove blank lines between import statements",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "import-squeeze": "bin.js"
8
+ },
9
+ "files": ["bin.js"],
10
+ "optionalDependencies": {
11
+ "@import-squeeze/darwin-arm64": "0.1.0",
12
+ "@import-squeeze/darwin-x64": "0.1.0",
13
+ "@import-squeeze/linux-x64": "0.1.0",
14
+ "@import-squeeze/win32-x64": "0.1.0"
15
+ }
16
+ }