Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ under the licensing terms detailed in LICENSE:
* Guido Zuidhof <[email protected]>
* ncave <[email protected]>
* Andrew Davis <[email protected]>
* Maël Nison <[email protected]>

Portions of this software are derived from third-party works licensed under
the following terms:
Expand Down
32 changes: 28 additions & 4 deletions bin/asinit
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ 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 (process.env.npm_config_user_agent.match(/\byarn\//))
pm = "yarn";
else if (process.env.npm_config_user_agent.match(/\bpnpm\//))
pm = "pnpm";

const asinitOptions = {
"help": {
"category": "General",
Expand Down Expand Up @@ -118,14 +142,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:",
Expand All @@ -146,7 +170,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:",
"",
Expand Down Expand Up @@ -289,7 +313,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": {
Expand Down