Skip to content

Commit

Permalink
Merge pull request #2 from dh-org/feat/pinia-install
Browse files Browse the repository at this point in the history
add install pinia
  • Loading branch information
0xhenrique authored Nov 14, 2023
2 parents 4f3dd65 + f713d29 commit 4d39f2f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::io;
use std::num::ParseIntError;

mod pinia;

fn main() {
let mut parsed_input: Result<u32, ParseIntError>;

Expand Down Expand Up @@ -37,7 +39,7 @@ fn print_options() {
}

fn install_pinia() {
println!("Installing Pinia...");
pinia::install();
}

fn install_husky() {
Expand Down
44 changes: 44 additions & 0 deletions src/pinia.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use std::process::Command;

pub fn install() {
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);
}
}
}
3 changes: 3 additions & 0 deletions src/pinia/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<h1>App.vue</h1>
</template>
4 changes: 4 additions & 0 deletions tmp/pinia/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...
})

0 comments on commit 4d39f2f

Please sign in to comment.