Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add install pinia #2

Merged
merged 3 commits into from
Nov 14, 2023
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
42 changes: 41 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::io;
use std::num::ParseIntError;
use std::process::Command;

fn main() {
let mut parsed_input: Result<u32, ParseIntError>;
Expand Down Expand Up @@ -37,7 +38,46 @@ fn print_options() {
}

fn install_pinia() {
println!("Installing Pinia...");
println!("Installing Pinia...");

let npm_install = Command::new("npm")
.arg("install")
.arg("pinia")
.spawn();

match npm_install {
Ok(mut child) => {
let status = child.wait().expect("Failed to wait for npm install");

if status.success() {
let mkdir_status = Command::new("mkdir")
.arg("store")
.status()
.expect("Failed to execute mkdir command");

if mkdir_status.success() {
let mv_status = Command::new("mv")
.arg("store.js")
.arg("./store/store.js")
.status()
.expect("Failed to execute mv command");

if mv_status.success() {
println!("Pinia successfully installed!");
} else {
println!("Failed to move store.js. mv command failed.");
}
} else {
println!("Failed to create the 'store' directory. mkdir command failed.");
}
} else {
println!("Failed to install Pinia. npm install command failed.");
}
}
Err(e) => {
println!("Failed to run npm install: {}", e);
}
}
}

fn install_husky() {
Expand Down
4 changes: 4 additions & 0 deletions store/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineStore } from 'pinia'
export const useAlertsStore = defineStore('alerts', {
// other options...
})