diff --git a/NOTICE b/NOTICE index bf9e9abd64..198b982544 100644 --- a/NOTICE +++ b/NOTICE @@ -25,6 +25,7 @@ under the licensing terms detailed in LICENSE: * Guido Zuidhof * ncave <777696+ncave@users.noreply.github.com> * Andrew Davis +* Maƫl Nison Portions of this software are derived from third-party works licensed under the following terms: diff --git a/bin/asinit b/bin/asinit index 557fc9c492..727534ba8e 100755 --- a/bin/asinit +++ b/bin/asinit @@ -8,6 +8,33 @@ const colors = require("../cli/util/colors"); const version = require("../package.json").version; const options = require("../cli/util/options"); +const commands = { + "npm": { + install: "npm install", + run: "npm run", + test: "npm test" + }, + "yarn": { + install: "yarn install", + run: "yarn", + test: "yarn test" + }, + "pnpm": { + install: "pnpm install", + run: "pnpm run", + test: "pnpm test" + } +}; + +let pm = "npm"; +if (typeof process.env.npm_config_user_agent === "string") { + if (/\byarn\//.test(process.env.npm_config_user_agent)) { + pm = "yarn"; + } else if (/\bpnpm\//.test(process.env.npm_config_user_agent)) { + pm = "pnpm"; + } +} + const asinitOptions = { "help": { "category": "General", @@ -118,14 +145,14 @@ function createProject(answer) { "", "Don't forget to install dependencies before you start:", "", - colors.white(" npm install"), + colors.white(" " + commands[pm].install), "", "To edit the entry file, open '" + colors.cyan("assembly/index.ts") + "' in your editor of choice.", "Create as many additional files as necessary and use them as imports.", "", "To build the entry file to WebAssembly when you are ready, run:", "", - colors.white(" npm run asbuild"), + colors.white(" " + commands[pm].run + " asbuild"), "", "Running the command above creates the following binaries incl. their respective", "text format representations and source maps:", @@ -146,7 +173,7 @@ function createProject(answer) { "", "To run the tests, do:", "", - colors.white(" npm test"), + colors.white(" " + commands[pm].test), "", "The AssemblyScript documentation covers all the details:", "", @@ -289,7 +316,7 @@ function ensurePackageJson() { const entryPath = path.relative(projectDir, entryFile).replace(/\\/g, "/"); const buildUntouched = "asc " + entryPath + " --target debug"; const buildOptimized = "asc " + entryPath + " --target release"; - const buildAll = "npm run asbuild:untouched && npm run asbuild:optimized"; + const buildAll = commands[pm].run + " asbuild:untouched && " + commands[pm].run + " asbuild:optimized"; if (!fs.existsSync(packageFile)) { fs.writeFileSync(packageFile, JSON.stringify({ "scripts": {