Skip to content

Commit

Permalink
Merge pull request #15 from kilork/14_npm_windows
Browse files Browse the repository at this point in the history
use cmd /c npm.cmd instead of just npm.cmd on windows
  • Loading branch information
kilork authored Aug 1, 2020
2 parents 65d36c7 + b3f1f1c commit 19eb032
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
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

0 comments on commit 19eb032

Please sign in to comment.