aboutsummaryrefslogtreecommitdiff
path: root/node_modules/node-cmd
diff options
context:
space:
mode:
authorPriyansh <[email protected]>2020-12-22 17:49:59 +0530
committerPriyansh <[email protected]>2020-12-22 17:49:59 +0530
commite93da8b04da86773247aadb1cbb1912e4f4526b2 (patch)
treeeb4ef3203a92ed3dbd2252ddb1ea23bd2d670c98 /node_modules/node-cmd
parenta5743c293dcb435e4b159a4df791f8955a4110ec (diff)
downloadstyx-e93da8b04da86773247aadb1cbb1912e4f4526b2.tar.xz
styx-e93da8b04da86773247aadb1cbb1912e4f4526b2.zip
Rewriting Project
Diffstat (limited to 'node_modules/node-cmd')
-rw-r--r--node_modules/node-cmd/.npmignore1
-rw-r--r--node_modules/node-cmd/README.md158
-rw-r--r--node_modules/node-cmd/cmd.js32
-rw-r--r--node_modules/node-cmd/commandline.js27
-rw-r--r--node_modules/node-cmd/example/basic.js28
-rw-r--r--node_modules/node-cmd/example/example.created.file0
-rw-r--r--node_modules/node-cmd/example/getPID.js4
-rw-r--r--node_modules/node-cmd/example/nodePythonTerminal.js27
-rw-r--r--node_modules/node-cmd/licence.md27
-rw-r--r--node_modules/node-cmd/package.json58
10 files changed, 362 insertions, 0 deletions
diff --git a/node_modules/node-cmd/.npmignore b/node_modules/node-cmd/.npmignore
new file mode 100644
index 0000000..8a4f50a
--- /dev/null
+++ b/node_modules/node-cmd/.npmignore
@@ -0,0 +1 @@
+/example/node-cmd/
diff --git a/node_modules/node-cmd/README.md b/node_modules/node-cmd/README.md
new file mode 100644
index 0000000..3afbf7a
--- /dev/null
+++ b/node_modules/node-cmd/README.md
@@ -0,0 +1,158 @@
+# node-cmd
+
+*Node.js commandline/terminal interface.*
+
+Simple commandline or terminal interface to allow you to run cli or bash style commands as if you were in the terminal.
+
+Run commands asynchronously, and if needed can get the output as a string.
+
+#### NPM Stats
+
+npm info :
+[![NPM](https://nodei.co/npm/node-cmd.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/node-cmd/)
+[See npm trends and stats for node-cmd](http://npm-stat.com/charts.html?package=node-cmd&author=&from=&to=)
+![node-cmd npm version](https://img.shields.io/npm/v/node-cmd.svg) ![supported node version for node-cmd](https://img.shields.io/node/v/node-cmd.svg) ![total npm downloads for node-cmd](https://img.shields.io/npm/dt/node-cmd.svg) ![monthly npm downloads for node-cmd](https://img.shields.io/npm/dm/node-cmd.svg) ![npm licence for node-cmd](https://img.shields.io/npm/l/node-cmd.svg)
+
+[![RIAEvangelist](https://avatars3.githubusercontent.com/u/369041?v=3&s=100)](https://github.com/RIAEvangelist)
+
+GitHub info :
+![node-cmd GitHub Release](https://img.shields.io/github/release/RIAEvangelist/node-cmd.svg) ![GitHub license node-cmd license](https://img.shields.io/github/license/RIAEvangelist/node-cmd.svg) ![open issues for node-cmd on GitHub](https://img.shields.io/github/issues/RIAEvangelist/node-cmd.svg)
+
+Package details websites :
+* [GitHub.io site](http://riaevangelist.github.io/node-cmd/ "node-cmd documentation"). A prettier version of this site.
+* [NPM Module](https://www.npmjs.org/package/node-cmd "node-cmd npm module"). The npm page for the node-cmd module.
+
+This work is licenced via the [DBAD Public Licence](http://www.dbad-license.org/).
+
+
+# Methods
+
+|method | arguments | functionality |
+|-------|-----------|---------------|
+|run | command | runs a command asynchronously|
+|get | command,callback | runs a command asynchronously, when the command is complete all of the stdout will be passed to the callback|
+
+
+## Examples
+
+```javascript
+
+ var cmd=require('node-cmd');
+
+ cmd.get(
+ 'pwd',
+ function(err, data, stderr){
+ console.log('the current working dir is : ',data)
+ }
+ );
+
+ cmd.run('touch example.created.file');
+
+ cmd.get(
+ 'ls',
+ function(err, data, stderr){
+ console.log('the current dir contains these files :\n\n',data)
+ }
+ );
+
+ cmd.get(
+ `
+ git clone https://github.com/RIAEvangelist/node-cmd.git
+ cd node-cmd
+ ls
+ `,
+ function(err, data, stderr){
+ if (!err) {
+ console.log('the node-cmd cloned dir contains these files :\n\n',data)
+ } else {
+ console.log('error', err)
+ }
+
+ }
+ );
+
+```
+
+## With promises
+
+this example by @stephen-last
+
+``` javascript
+
+import Promise from 'bluebird'
+import cmd from 'node-cmd'
+
+const getAsync = Promise.promisify(cmd.get, { multiArgs: true, context: cmd })
+
+getAsync('node -v').then(data => {
+ console.log('cmd data', data)
+}).catch(err => {
+ console.log('cmd err', err)
+})
+
+```
+
+## Accessing the CMD Process
+If you need PIDs, stdio,stdin, stdout, stderr, etc. access, for use in your code, or cleaning up, @freemany added in some functionality to get a reference to the child process as the returned value of the ` get ` and ` run ` calls.
+
+
+### Getting Process ID
+
+```javascript
+
+ var cmd=require('../cmd.js');
+
+ var process=cmd.get('node');
+ console.log(process.pid);
+
+```
+
+### Running a python shell from node
+
+```javascript
+const cmd=require('../cmd.js');
+
+const processRef=cmd.get('python -i');
+let data_line = '';
+
+//listen to the python terminal output
+processRef.stdout.on(
+ 'data',
+ function(data) {
+ data_line += data;
+ if (data_line[data_line.length-1] == '\n') {
+ console.log(data_line);
+ }
+ }
+);
+
+const pythonTerminalInput=`primes = [2, 3, 5, 7]
+for prime in primes:
+ print(prime)
+
+`;
+
+//show what we are doing
+console.log(`>>>${pythonTerminalInput}`);
+
+//send it to the open python terminal
+processRef.stdin.write(pythonTerminalInput);
+
+```
+
+Output :
+
+```python
+
+>>>primes = [2, 3, 5, 7]
+for prime in primes:
+ print(prime)
+
+
+2
+3
+5
+7
+
+
+```
diff --git a/node_modules/node-cmd/cmd.js b/node_modules/node-cmd/cmd.js
new file mode 100644
index 0000000..4cc4a1d
--- /dev/null
+++ b/node_modules/node-cmd/cmd.js
@@ -0,0 +1,32 @@
+var exec = require('child_process').exec;
+
+var commandline={
+ get:getString,
+ run:runCommand
+};
+
+function runCommand(command){
+ //return refrence to the child process
+ return exec(
+ command
+ );
+}
+
+function getString(command,callback){
+ //return refrence to the child process
+ return exec(
+ command,
+ (
+ function(){
+ return function(err,data,stderr){
+ if(!callback)
+ return;
+
+ callback(err, data, stderr);
+ }
+ }
+ )(callback)
+ );
+}
+
+module.exports=commandline;
diff --git a/node_modules/node-cmd/commandline.js b/node_modules/node-cmd/commandline.js
new file mode 100644
index 0000000..425ea97
--- /dev/null
+++ b/node_modules/node-cmd/commandline.js
@@ -0,0 +1,27 @@
+var exec = require('child_process').exec;
+
+var commandline={
+ get:getString,
+ run:runCommand
+};
+
+function runCommand(command){
+ exec(
+ command
+ );
+}
+
+function getString(command,callback){
+ exec(
+ command,
+ (
+ function(){
+ return function(err,data,stderr){
+ callback(data,err,stderr);
+ }
+ }
+ )(callback)
+ );
+}
+
+module.exports=commandline;
diff --git a/node_modules/node-cmd/example/basic.js b/node_modules/node-cmd/example/basic.js
new file mode 100644
index 0000000..66fcc54
--- /dev/null
+++ b/node_modules/node-cmd/example/basic.js
@@ -0,0 +1,28 @@
+var cmd=require('../cmd.js');
+
+cmd.get(
+ 'pwd',
+ function(data){
+ console.log('the current working dir is : ',data)
+ }
+);
+
+cmd.run('touch example.created.file');
+
+cmd.get(
+ 'ls',
+ function(data){
+ console.log('the current dir contains these files :\n\n',data)
+ }
+);
+
+cmd.get(
+ `
+ git clone https://github.com/RIAEvangelist/node-cmd.git
+ cd node-cmd
+ ls
+ `,
+ function(data){
+ console.log('the node-cmd clone dir contains these files :\n\n',data)
+ }
+);
diff --git a/node_modules/node-cmd/example/example.created.file b/node_modules/node-cmd/example/example.created.file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/node_modules/node-cmd/example/example.created.file
diff --git a/node_modules/node-cmd/example/getPID.js b/node_modules/node-cmd/example/getPID.js
new file mode 100644
index 0000000..e5946d4
--- /dev/null
+++ b/node_modules/node-cmd/example/getPID.js
@@ -0,0 +1,4 @@
+var cmd=require('../cmd.js');
+
+var processRef=cmd.get('node');
+console.log(processRef.pid);
diff --git a/node_modules/node-cmd/example/nodePythonTerminal.js b/node_modules/node-cmd/example/nodePythonTerminal.js
new file mode 100644
index 0000000..59d16e2
--- /dev/null
+++ b/node_modules/node-cmd/example/nodePythonTerminal.js
@@ -0,0 +1,27 @@
+const cmd=require('../cmd.js');
+
+const processRef=cmd.get('python -i');
+let data_line = '';
+
+//listen to the python terminal output
+processRef.stdout.on(
+ 'data',
+ function(data) {
+ data_line += data;
+ if (data_line[data_line.length-1] == '\n') {
+ console.log(data_line);
+ }
+ }
+);
+
+const pythonTerminalInput=`primes = [2, 3, 5, 7]
+for prime in primes:
+ print(prime)
+
+`;
+
+//show what we are doing
+console.log(`>>>${pythonTerminalInput}`);
+
+//send it to the open python terminal
+processRef.stdin.write(pythonTerminalInput);
diff --git a/node_modules/node-cmd/licence.md b/node_modules/node-cmd/licence.md
new file mode 100644
index 0000000..9169a8f
--- /dev/null
+++ b/node_modules/node-cmd/licence.md
@@ -0,0 +1,27 @@
+# DON'T BE A DICK PUBLIC LICENSE
+
+> Version 1, December 2009
+
+> Copyright (C) 2009 Philip Sturgeon <[email protected]>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+> DON'T BE A DICK PUBLIC LICENSE
+> TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 1. Do whatever you like with the original work, just don't be a dick.
+
+ Being a dick includes - but is not limited to - the following instances:
+
+ 1a. Outright copyright infringement - Don't just copy this and change the name.
+ 1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
+ 1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.
+
+ 2. If you become rich through modifications, related works/services, or supporting the original work,
+ share the love. Only a dick would make loads off this work and not buy the original work's
+ creator(s) a pint.
+
+ 3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes
+ you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.
diff --git a/node_modules/node-cmd/package.json b/node_modules/node-cmd/package.json
new file mode 100644
index 0000000..330e1b5
--- /dev/null
+++ b/node_modules/node-cmd/package.json
@@ -0,0 +1,58 @@
+{
+ "_from": "node-cmd@^3.0.0",
+ "_id": "[email protected]",
+ "_inBundle": false,
+ "_integrity": "sha1-OP/3CkqqT2WdID61eGJzcBjiT28=",
+ "_location": "/node-cmd",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "node-cmd@^3.0.0",
+ "name": "node-cmd",
+ "escapedName": "node-cmd",
+ "rawSpec": "^3.0.0",
+ "saveSpec": null,
+ "fetchSpec": "^3.0.0"
+ },
+ "_requiredBy": [
+ "/"
+ ],
+ "_resolved": "https://registry.npmjs.org/node-cmd/-/node-cmd-3.0.0.tgz",
+ "_shasum": "38fff70a4aaa4f659d203eb57862737018e24f6f",
+ "_spec": "node-cmd@^3.0.0",
+ "_where": "/Users/lucifer/Documents/styx",
+ "author": {
+ "name": "Brandon Nozaki Miller"
+ },
+ "bugs": {
+ "url": "https://github.com/RIAEvangelist/node-cmd/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "Simple commandline/terminal interface to allow you to run cli or bash style commands as if you were in the terminal.",
+ "directories": {
+ "example": "example"
+ },
+ "homepage": "https://github.com/RIAEvangelist/node-cmd",
+ "keywords": [
+ "commandline",
+ "terminal",
+ "cmd",
+ "cli",
+ "bash",
+ "script",
+ "node"
+ ],
+ "license": "DBAD",
+ "main": "cmd.js",
+ "name": "node-cmd",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/RIAEvangelist/node-cmd.git"
+ },
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "version": "3.0.0"
+}