@Override protected NodeTask newTask(FrontendPluginFactory factory, Config conf, ProxyConfig proxy, Map<String, String> env, String nodeVersion) throws InstallationException { Function<String, String> property = key -> conf.hasPath(key) ? conf.getString(key) : null; factory.getNPMInstaller(proxy) .setNpmVersion(npmVersion) .setNodeVersion(nodeVersion) .setNpmDownloadRoot(conf.getString("npm.downloadRoot")) .setUserName(property.apply("npm.username")) .setPassword(property.apply("npm.password")) .install(); NpmRunner npm = factory.getNpmRunner(proxy, conf.getString("npm.registryURL")); return (cmd, args) -> { String cmdline = cmd + " " + Arrays.asList(args).stream().collect(Collectors.joining(" ")); npm.execute(cmdline, env); }; }
@Override public void execute(FrontendPluginFactory factory) throws TaskRunnerException { File packageJson = new File(workingDirectory, "package.json"); if (buildContext == null || buildContext.hasDelta(packageJson) || !buildContext.isIncremental()) { ProxyConfig proxyConfig = getProxyConfig(); factory.getNpmRunner(proxyConfig, getRegistryUrl()).execute(arguments, environmentVariables); } else { getLog().info("Skipping npm install as package.json unchanged"); } }
/** * Configures the NPM registry location. * * @param node the node manager * @param log the logger * @param npmRegistryUrl the registry url */ public static void configureRegistry(NodeManager node, Log log, String npmRegistryUrl) { try { node.factory().getNpmRunner(node.proxy()).execute("config set registry " + npmRegistryUrl); } catch (TaskRunnerException e) { log.error("Error during the configuration of NPM registry with the url " + npmRegistryUrl + " - check log", e); } }
node.factoryForNPMInstallation().getNpmRunner(node.proxy()).execute(command.toString()); } catch (TaskRunnerException e) { log.error("Error during the installation of the NPM " + npmName + " - check log", e);
@Override public void execute(FrontendPluginFactory factory) throws TaskRunnerException { File packageJson = new File(workingDirectory, "package.json"); if (buildContext == null || buildContext.hasDelta(packageJson) || !buildContext.isIncremental()) { ProxyConfig proxyConfig = getProxyConfig(); factory.getNpmRunner(proxyConfig, getRegistryUrl()).execute(arguments, environmentVariables); } else { getLog().info("Skipping npm install as package.json unchanged"); } }