You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.2 KiB
36 lines
1.2 KiB
<?php
|
|
|
|
namespace utils;
|
|
|
|
class npm {
|
|
|
|
public static function install($program) {
|
|
exec(\neato::get_user_local_bin . 'npm install -g ' . safeCmd($program), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to run npm install command: {$program}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function uninstall($program) {
|
|
exec(\neato::get_user_local_bin . 'npm uninstall ' . safeCmd($program), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to run npm uninstall command: {$program}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function is_package_installed_globally($program, $display = false) {
|
|
exec(\neato::get_user_local_bin . 'npm list -g ' . safeCmd($program), $output, $exit_code);
|
|
if ($display === true) {
|
|
checkForError($exit_code, "npm package not installed: {$program}");
|
|
}
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function update($program) {
|
|
exec(\neato::get_user_local_bin . 'npm update -g ' . safeCmd($program), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to run npm update command: {$program}");
|
|
return $exit_code;
|
|
}
|
|
|
|
} |