generated from LinuxSuRen/github-go
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to install tool via npm (#264)
- Loading branch information
1 parent
b623013
commit aa11a0f
Showing
3 changed files
with
59 additions
and
3 deletions.
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
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,51 @@ | ||
package npm | ||
|
||
import ( | ||
"fmt" | ||
"github.com/linuxsuren/http-downloader/pkg/exec" | ||
) | ||
|
||
// NPMName is the name of npm | ||
const NPMName = "npm" | ||
|
||
// CommonInstaller is the installer of a common npm | ||
type CommonInstaller struct { | ||
Name string | ||
} | ||
|
||
// Available check if support current platform | ||
func (d *CommonInstaller) Available() (ok bool) { | ||
_, err := exec.LookPath("npm") | ||
ok = err == nil | ||
return | ||
} | ||
|
||
// Install installs the target package | ||
func (d *CommonInstaller) Install() (err error) { | ||
err = exec.RunCommand("npm", "i", "-g", d.Name) | ||
return | ||
} | ||
|
||
// Uninstall uninstalls the target package | ||
func (d *CommonInstaller) Uninstall() (err error) { | ||
err = exec.RunCommand("npm", "uninstall", "-g", d.Name) | ||
return | ||
} | ||
|
||
// WaitForStart waits for the service be started | ||
func (d *CommonInstaller) WaitForStart() (ok bool, err error) { | ||
ok = true | ||
return | ||
} | ||
|
||
// Start starts the target service | ||
func (d *CommonInstaller) Start() error { | ||
fmt.Println("not supported yet") | ||
return nil | ||
} | ||
|
||
// Stop stops the target service | ||
func (d *CommonInstaller) Stop() error { | ||
fmt.Println("not supported yet") | ||
return nil | ||
} |