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

use cmd /c npm.cmd instead of just npm.cmd on windows #15

Merged
merged 4 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on: [push]
jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v1
Expand Down
20 changes: 18 additions & 2 deletions src/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ impl NpmBuild {

/// Executes `npm install`.
pub fn install(self) -> io::Result<Self> {
if let Err(e) = Command::new(&self.executable)
if let Err(e) = self
.command()
.arg("install")
.current_dir(&self.package_json_dir)
.status()
Expand All @@ -568,7 +569,8 @@ impl NpmBuild {

/// Executes `npm run CMD`.
pub fn run(self, cmd: &str) -> io::Result<Self> {
if let Err(e) = Command::new(&self.executable)
if let Err(e) = self
.command()
.arg("run")
.arg(cmd)
.current_dir(&self.package_json_dir)
Expand All @@ -591,6 +593,20 @@ impl NpmBuild {
pub fn to_resource_dir(self) -> ResourceDir {
self.into()
}

#[cfg(not(windows))]
fn command(&self) -> Command {
Command::new(&self.executable)
}

#[cfg(windows)]
fn command(&self) -> Command {
let mut cmd = Command::new("cmd");

cmd.arg("/c").arg(&self.executable);

cmd
}
}

impl From<NpmBuild> for ResourceDir {
Expand Down