Skip to content

Commit 02acd4f

Browse files
Pauansendilkumarn
authored andcommitted
Fixing the install script
1 parent d833abc commit 02acd4f

File tree

4 files changed

+151
-5
lines changed

4 files changed

+151
-5
lines changed

.bin/create-rust-webpack.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
const { spawnSync } = require("child_process");
44
const fs = require("fs");
5+
const path = require("path");
6+
const cpr = require("cpr");
7+
const rimraf = require("rimraf");
58

69
function run(cmd, args, opts) {
710
const output = spawnSync(cmd, args, opts);
@@ -24,10 +27,24 @@ if (process.argv.length >= 3) {
2427
}
2528
}
2629

27-
run("git", ["clone", "--no-tags", "--depth", "0", "https://github.com/rustwasm/rust-webpack-template.git", path.join(folderName, "git-clone")]);
30+
let gitFolder = path.join(folderName, "git-clone");
2831

29-
console.log(" 🦀 Rust + 🕸 WebAssembly + Webpack = ❤️ ");
32+
// This uses --no-tags and --depth 1 in order to make the cloning faster
33+
run("git", ["clone", "--no-tags", "--depth", "1", "https://github.com/rustwasm/rust-webpack-template.git", gitFolder]);
3034

31-
run("npm", ["install"], { cwd: folderName, shell: true });
35+
// Copies the template folder
36+
cpr(path.join(gitFolder, "template"), folderName, {}, function (err, files) {
37+
// Removes the git folder regardless of whether cpr succeeded or not
38+
rimraf.sync(gitFolder);
3239

33-
console.log(" Installed dependencies ✅ ");
40+
if (err) {
41+
throw err;
42+
43+
} else {
44+
console.log(" 🦀 Rust + 🕸 WebAssembly + Webpack = ❤️ ");
45+
46+
run("npm", ["install"], { cwd: folderName, shell: true });
47+
48+
console.log(" Installed dependencies ✅ ");
49+
}
50+
});

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
/template/package-lock.json
33
/template/Cargo.lock
4+
/template/git-clone

package-lock.json

Lines changed: 125 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
"license": "(MIT OR Apache-2.0)",
77
"bin": {
88
"create-rust-webpack": ".bin/create-rust-webpack.js"
9+
},
10+
"dependencies": {
11+
"cpr": "^3.0.1",
12+
"rimraf": "^2.6.3"
913
}
1014
}

0 commit comments

Comments
 (0)