rust_to_npm/generators/
mod.rs

1pub mod package;
2pub mod pre_install;
3pub mod start;
4pub mod uninstall;
5
6/// start the install scripts
7pub fn generate_installs() -> &'static str {
8    r#"#!/usr/bin/env node
9
10const fs = require("fs");
11const path = require("path");
12const { exec } = require("child_process");
13const { homedir } = require("os");
14
15const cargoDir = path.join(homedir(), ".cargo");
16
17// check if directory exists
18if (fs.existsSync(cargoDir)) {
19  //   console.log("Cargo found.");
20} else {
21  const setCargo = 'PATH="/$HOME/.cargo/bin:${PATH}"';
22  console.log("Installing deps [cargo].");
23
24  exec(
25    `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && ${setCargo}`,
26    (error) => {
27      if (error) {
28        console.log(
29          "curl failed! Curl may not be installed on the OS. View https://curl.se/download.html to install."
30        );
31        console.log(error);
32      }
33    }
34  );
35}
36    "#
37}
38
39// /// generate .gitignore
40// pub fn generate_git_ignore() -> &'static str  {
41//     r#".DS_Store
42// /target
43// package.json
44// package-lock.json
45// start.js
46// uninstall.js
47// pre-install.js
48//     "#
49// }