create env.sh
a shell script that helps to set the environment for npm
This commit is contained in:
1
pdb-js/.gitignore
vendored
1
pdb-js/.gitignore
vendored
@@ -46,3 +46,4 @@ testem.log
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
/env.sh
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user