create env.sh

a shell script that helps to set the environment for npm
This commit is contained in:
2021-04-22 19:20:07 +02:00
parent 546c096dad
commit ae545e602c
2 changed files with 28 additions and 1 deletions

View File

@@ -1,3 +1,6 @@
import java.nio.file.Files
import java.nio.file.Paths
plugins {
id("com.github.node-gradle.node") version "3.0.1"
}
@@ -9,7 +12,7 @@ node {
version = version_nodejs
// Version of npm to use. Uses the version included in nodejs if not set.
npmVersion = version_npm
//npmVersion = version_npm
// Version of Yarn to use.
//yarnVersion = '0.16.1'
@@ -60,3 +63,26 @@ jar {
dependencies {
}
task createEnvShell {
final String cwd = file(".").getAbsolutePath();
final File script = file("env.sh");
final String nodejsPath = "${cwd}/.gradle/nodejs/node-v${version_nodejs}-linux-x64/bin";
final String npmPath = "${cwd}/build/npm/npm-v${version_npm}/bin";
final String nodeModulesBinPath = "${cwd}/node_modules/.bin";
final String content = '#usage: source env.sh'+"\nexport PATH=${nodeModulesBinPath}:${npmPath}:${nodejsPath}:\$PATH\n";
inputs.property("version_nodejs", version_nodejs)
inputs.property("version_npm", version_npm)
inputs.property("content", content)
outputs.file(script)
doLast {
println 'create environment shell script'
Files.writeString(script.toPath(), content);
}
}
tasks['eclipse'].dependsOn createEnvShell