Comparing version 0.0.1 to 0.0.2
48
dorun.js
#!/usr/bin/env node | ||
'use strict' | ||
"use strict"; | ||
var mountPath = "/work/input"; | ||
var dockerPreArgs = "-it --rm"; | ||
// @STCGoal Whatever the platform, the docker runs with the current dir mounted as /work/input | ||
// | ||
var os = require("os"); | ||
var myArgs = process.argv.slice(2); | ||
//@STCGoal Platform | ||
var p = process.platform; | ||
console.log("LINUX>docker run -it --rm $(pwd)/:/work/input $1"); | ||
console.log("PowerShell>docker run -it --rm ${pwd}/:/work/input $1"); | ||
console.log("WIN>docker run -it --rm %cd%/:/work/input $1"); | ||
if (myArgs[0] == "--testos") { | ||
console.log(p); | ||
console.log(os.type()); // "Windows_NT" | ||
console.log(os.release()); // "10.0.14393" | ||
console.log(os.platform()); // "win32" | ||
} | ||
var cdirString = ""; | ||
console.log("Nodejs How to detect platform context ? ") | ||
if (p == "linux") { | ||
cdirString = "$(pwd)/"; | ||
} else if (p == "win32") { | ||
//win | ||
cdirString = "${pwd}/"; | ||
} else if (p == "cygwin") { | ||
//win | ||
cdirString = "%cd%"; | ||
} else cdirString = "$(pwd)/"; | ||
if (myArgs[0] == "--help") { | ||
console.log("LINUX>docker run -it --rm $(pwd)/:/work/input $1"); | ||
console.log("PowerShell>docker run -it --rm ${pwd}/:/work/input $1"); | ||
console.log("WIN>docker run -it --rm %cd%/:/work/input $1"); | ||
} | ||
var cmdAndArgs = " " | ||
myArgs.forEach(a => { | ||
cmdAndArgs += a + " "; | ||
}); | ||
//@STCGoal Support X11Forwarding | ||
//@action $(/sbin/ip route|awk '/default/ { print $3 }'):0 | ||
console.log(`docker run ${dockerPreArgs} -v ${cdirString}:${mountPath} ${cmdAndArgs }`); | ||
// console.log("Nodejs How to detect platform context ? "); | ||
//@STCGoal ... |
{ | ||
"name": "dorun", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Run a docker container with current dir mounted as /work/input", | ||
@@ -5,0 +5,0 @@ "main": "dorun.js", |
# dorun | ||
Docker run and mount current dir | ||
##--@STCStatus In progress | ||
## Install | ||
```sh | ||
sudo npm i dorun --g | ||
``` | ||
## Usage | ||
```sh | ||
dorun jgwill/ubuntu | ||
```` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3129
5
40
16
0