-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bf3030
commit def8db9
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package checks | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
/* | ||
check = "npm.install" | ||
Passes if npm dependencies are installed. | ||
This is implemented with the `npm ls` command, | ||
so npm must be installed and on the PATH already. | ||
- package: A string with the path to a package.json file. | ||
*/ | ||
type CheckNpmInstall struct{} | ||
|
||
func (n CheckNpmInstall) Run(p Params) CheckResult { | ||
packageFile := p.GetString("package") | ||
|
||
_, err := os.Lstat(packageFile) | ||
if os.IsNotExist(err) { | ||
return newBasicResult(false, packageFile+" does not exist") | ||
} | ||
|
||
dir := filepath.Dir(packageFile) | ||
|
||
cmd := exec.Command("npm", "ls") | ||
cmd.Dir = dir | ||
err = cmd.Start() | ||
if err != nil { | ||
return newBasicResult(false, fmt.Sprintf("npm in %s: %s", dir, err)) | ||
} | ||
|
||
err = cmd.Wait() | ||
if err != nil { | ||
return newBasicResult(false, packageFile+" dependencies not satisfied") | ||
} | ||
|
||
return newBasicResult(true, packageFile+" dependencies") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
check = "npm.install" | ||
|
||
Passes if npm dependencies are installed. | ||
This is implemented with the `npm ls` command, | ||
so npm must be installed and on the PATH already. | ||
|
||
- package: A string with the path to a package.json file. |