@@ -13,22 +13,36 @@ func genInfoEslint(r *Runtime) map[string]string {
1313
1414 return map [string ]string {
1515 "installDir" : installDir ,
16- "eslint" : path .Join (installDir , "node_modules" , ".bin" , "eslint" ),
16+ "eslint" : path .Join (installDir , "node_modules" , ".bin" , "eslint" ),
1717 }
1818}
1919
2020/*
2121 * This installs eslint using node's npm alongside its sarif extension
2222 */
23- func InstallEslint (nodeRuntime * Runtime , eslint * Runtime ) error {
23+ func InstallEslint (nodeRuntime * Runtime , eslint * Runtime , registry string ) error {
2424 log .Println ("Installing ESLint" )
2525
2626 eslintInstallArg := fmt .Sprintf ("%s@%s" , eslint .Name (), eslint .Version ())
27+ if registry != "" {
28+ fmt .Println ("Using registry:" , registry )
29+ configCmd := exec .Command (nodeRuntime .Info ()["npm" ], "config" , "set" , "registry" , registry )
30+ if configOut , err := configCmd .Output (); err != nil {
31+ fmt .Println ("Error setting npm registry:" , err )
32+ fmt .Println (string (configOut ))
33+ return err
34+ }
35+ }
2736 cmd := exec .Command (nodeRuntime .Info ()["npm" ], "install" , "--prefix" , eslint .Info ()["installDir" ],
2837 eslintInstallArg , "@microsoft/eslint-formatter-sarif" )
38+ fmt .Println (cmd .String ())
2939 // to use the chdir command we needed to create the folder before, we can change this after
3040 // cmd.Dir = eslintInstallationFolder
3141 stdout , err := cmd .Output ()
42+ if err != nil {
43+ fmt .Println ("Error installing ESLint:" , err )
44+ fmt .Println (string (stdout ))
45+ }
3246 // Print the output
3347 fmt .Println (string (stdout ))
3448 return err
0 commit comments