diff --git a/cli/npm/.gitignore b/cli/npm/.gitignore index f0475945..2d3aa23a 100644 --- a/cli/npm/.gitignore +++ b/cli/npm/.gitignore @@ -1,3 +1,4 @@ tree-sitter tree-sitter.exe *.gz +*.tgz diff --git a/cli/npm/cli.js b/cli/npm/cli.js new file mode 100755 index 00000000..404739fa --- /dev/null +++ b/cli/npm/cli.js @@ -0,0 +1,12 @@ +#!/usr/bin/env node + +const path = require('path'); +const spawn = require("child_process").spawn; +const executable = process.platform === 'win32' + ? 'tree-sitter.exe' + : 'tree-sitter'; +spawn( + path.join(__dirname, executable), + process.argv.slice(2), + {stdio: 'inherit'} +).on('close', process.exit) diff --git a/cli/npm/package.json b/cli/npm/package.json index 0155c8da..230676f1 100644 --- a/cli/npm/package.json +++ b/cli/npm/package.json @@ -17,6 +17,6 @@ "install": "node install.js" }, "bin": { - "tree-sitter": "tree-sitter" + "tree-sitter": "cli.js" } }