Skip to content

Commit 7a9a9b1

Browse files
committed
build: adjust bin
Signed-off-by: Chapman Pendery <[email protected]>
1 parent 9c04ed3 commit 7a9a9b1

File tree

5 files changed

+67
-7
lines changed

5 files changed

+67
-7
lines changed

Formula/inshellisense.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Inshellisense < Formula
2+
desc "IDE style command line auto complete"
3+
homepage "https://github.com/microsoft/inshellisense"
4+
url "https://registry.npmjs.org/@microsoft/inshellisense/-/inshellisense-0.0.1-rc.25.tgz"
5+
sha256 ""
6+
license "MIT"
7+
8+
depends_on "node"
9+
10+
def install
11+
system "npm", "install", *std_npm_args
12+
bin.install_symlink libexec.glob("bin/*")
13+
end
14+
15+
test do
16+
system bin/"inshellisense", "--version"
17+
end
18+
end
19+

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88

99
### Installation
1010

11-
**npm**
11+
**npm (recommended)**
1212
```shell
1313
npm install -g @microsoft/inshellisense
1414
is init
1515
```
16+
**homebrew (macOS/linux)**
17+
```shell
18+
brew tap microsoft/inshellisense https://github.com/microsoft/inshellisense
19+
brew install inshellisense
20+
is init
21+
```
1622

1723
### Updating
1824

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/inshellisense",
3-
"version": "0.0.1-rc.24",
3+
"version": "0.0.1-rc.25",
44
"description": "IDE style command line auto complete",
55
"type": "module",
66
"engines": {
@@ -50,7 +50,7 @@
5050
"color-convert": "^2.0.1",
5151
"commander": "^11.0.0",
5252
"find-process": "^1.4.7",
53-
"node-pty": "1.2.0-beta.6",
53+
"node-pty": "1.2.0-beta.1",
5454
"strip-ansi": "^7.1.0",
5555
"toml": "^3.0.0",
5656
"uuid": "^11.1.0",

scripts/bin.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env node
2+
// Copyright (c) Microsoft Corporation.
3+
// Licensed under the MIT License.
4+
5+
const { spawnSync } = require("child_process");
6+
const path = require("path");
7+
8+
const platform = process.platform;
9+
const arch = process.arch;
10+
11+
const platformArch = `${platform}-${arch}`;
12+
const packageName = `@microsoft/inshellisense-${platformArch}`;
13+
const binaryName = platform === "win32"
14+
? `inshellisense-${platformArch}.exe`
15+
: `inshellisense-${platformArch}`;
16+
17+
try {
18+
const platformPkgPath = require.resolve(`${packageName}/package.json`);
19+
const platformPkgDir = path.dirname(platformPkgPath);
20+
const binaryPath = path.join(platformPkgDir, binaryName);
21+
22+
const result = spawnSync(binaryPath, process.argv.slice(2), {
23+
stdio: "inherit",
24+
shell: false,
25+
});
26+
27+
process.exit(result.status ?? 1);
28+
} catch (err) {
29+
console.error(`inshellisense: Platform ${platformArch} is not supported.`);
30+
console.error(err.message);
31+
process.exit(1);
32+
}

scripts/pkg-base.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import path from "node:path";
77

88
// Constants
99
const PKG_DIR = "pkg";
10+
const SCRIPTS_DIR = "scripts";
1011

1112
const getVersion = (): string => {
1213
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf-8"));
@@ -19,6 +20,7 @@ const copyFiles = (): void => {
1920
fs.copyFileSync(file, path.join(PKG_DIR, file));
2021
}
2122
fs.copyFileSync("LICENSE", path.join(PKG_DIR, "LICENSE"));
23+
fs.copyFileSync(path.join(SCRIPTS_DIR, "bin.js"), path.join(PKG_DIR, "bin.js"));
2224
};
2325

2426
const generatePackageJson = (): void => {
@@ -37,10 +39,11 @@ const generatePackageJson = (): void => {
3739
bugs: {
3840
url: "https://github.com/microsoft/inshellisense/issues",
3941
},
40-
files: [
41-
"*.md",
42-
"LICENSE",
43-
],
42+
bin: {
43+
is: "bin.js",
44+
inshellisense: "bin.js",
45+
},
46+
files: ["*.md", "LICENSE", "bin.js"],
4447
optionalDependencies: {
4548
"@microsoft/inshellisense-darwin-x64": getVersion(),
4649
"@microsoft/inshellisense-darwin-arm64": getVersion(),

0 commit comments

Comments
 (0)