Commit 13386ac1 authored by Konrad Borowski's avatar Konrad Borowski

Merge branch 'remove-npm-install-from-build-rs' into 'master'

Remove npm install from build.rs

See merge request pastebin.run/server!72
parents bae8c543 07134ed7
Pipeline #96971149 passed with stage
in 9 minutes and 17 seconds
build:
image: rust:latest
script:
- apt update
- apt install -y npm
- &print_version rustc --version && cargo --version
- &init
- apt update
- apt install -y npm
- rustc --version && cargo --version
- npm ci
- node_modules/.bin/webpack
- cargo build --release --verbose
artifacts:
paths:
......@@ -13,7 +16,6 @@ build:
cache:
key: release
paths:
- node_modules/
- target/
test:stable: &test
......@@ -25,12 +27,9 @@ test:stable: &test
POSTGRES_PASSWORD: password
image: rust:latest
script:
- apt update
- apt install -y npm
- *print_version
- *init
- DATABASE_URL=postgresql://user:password@postgres/db cargo test --verbose --features=database_tests
cache:
key: debug
paths:
- node_modules/
- target/
use ructe::Ructe;
use std::error::Error;
use ructe::{Result, Ructe};
use std::fs;
use std::process::{Command, Stdio};
use walkdir::WalkDir;
fn run_command(command: &str, if_fails: &str) {
if !Command::new("sh")
.args(&["-c", &format!("{} 1>&2", command)])
.stdout(Stdio::null())
.status()
.unwrap()
.success()
{
panic!("{}", if_fails);
}
}
fn main() -> Result<(), Box<dyn Error>> {
for file in WalkDir::new("js") {
println!("cargo:rerun-if-changed={}", file?.path().display());
}
println!("cargo:rerun-if-changed=webpack.config.js");
run_command("npm install", "Installing npm modules failed");
run_command("node_modules/.bin/webpack", "Webpack failed");
fn main() -> Result<()> {
println!(
"cargo:rustc-env=ENTRY_FILE_PATH={}",
fs::read_to_string("entry")?,
fs::read_to_string("entry").expect("Please use webpack to generate JavaScript"),
);
Ructe::from_env()
.unwrap()
.compile_templates("templates")
.unwrap();
Ok(())
Ructe::from_env()?.compile_templates("templates")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment