Giter Club home page Giter Club logo

oh-my-terminal's Introduction

oh-my-terminal

Last version Build Status Dependency status Dev Dependencies Status NPM Status Donate

Simple and unmistakable terminal interface for NodeJS.

Why

  • Based in NodeJS exec and spawn native interface.
  • Automatically provide a polyfill for non native compatible node versions (for example, execSync under 0.10).
  • Uniform methods for synchronously and asynchronously, just decide providing or not a callback.
  • Little improvements, like posibility for run a set of commands in the same command or more information about the process status in sync versions.

Install

npm install oh-my-terminal --save

Example

First load the library:

var terminal = require('oh-my-terminal');

Simple Usage

Now, you can run a command using exec or spawn methods. Exists slight difference between us (as you know from child_process.

Using exec:

var term = terminal.exec('echo hello world');

console.log(term);
// => {
//   stdout: 'hello world\n',
//   stderr: '',
//   status: 0
// }

Using spawn:

var term = terminal.spawn('echo hello world');

console.log(term);
// => {
//   pid: 95109,
//   output: [ null, 'hello world\n', '' ],
//   stdout: 'hello world\n',
//   stderr: '',
//   status: 0,
//   signal: null
// }

Custom Options

Like exec or spawn, you can provide a custom options for the command:

var options = {
  timeout: 1000
};
var term = terminal.exec('echo hello world', options);

console.log(term.stdout);
// => 'hello world\n'

More than one

If you need to run one command, maybe you need to run more than one. Just instead of string pass an array of command (with or without callback for user synchronously or asynchronously behavior):

terminal.exec(['echo hello', 'echo world'], function(err, commands) {
  console.log(commands[0].stdout);
  // => 'hello world\n'
  console.log(commands[1].stdout);
  // => 'hello world\n'
});

Async mode

Just providing a standard NodeJS callback you activate the async mode for the command:

terminal.exec('echo hello world', function(err, command) {
  console.log(command.stdout);
  // => 'hello world\n'
});

You can run a set of command in async mode as well:

terminal.exec(['echo hello world', 'echo hello world'], function(err, commands) {
  console.log(commands[0].stdout);
  // => 'hello world\n'
  console.log(commands[1].stdout);
  // => 'hello world\n'
});

API

.exec(<command[s]>, [options], [callback])

Invoke child_process.exec (or execSync if you don't provide a callback) function. You can provide just one String command or an Array of command to be executed.

Options are child_process.exec options. { encoding: 'utf8' } by default.

.spawn(<command[s]>, [options], [callback])

Invoke child_process.spawn (or spawnSync if you don't provide a callback) function. You can provide just one String command or an Array of command to be executed.

Options are child_process.spawn options. { encoding: 'utf8' } by default.

Note that in this case the response is a Stream Object that starts sending back data from the child process in a stream as soon as the child process starts executing.

License

MIT © Kiko Beats

oh-my-terminal's People

Contributors

greenkeeper[bot] avatar kikobeats avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

oh-my-terminal's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

An in-range update of mocha is breaking the build 🚨

Version 4.0.1 of mocha was just published.

Branch Build failing 🚨
Dependency mocha
Current Version 4.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v4.0.1

4.0.1 / 2017-10-05

🐛 Fixes

Commits

The new version differs by 6 commits.

  • eb8bf8d Release v4.0.1
  • 3b485ea update CHANGELOG.md for v4.0.1 [ci skip]
  • 96e5c1a upgrade eslint to v4.8.0
  • d7cff37 Update growl to 1.10.3
  • 0cdd921 remove preversion script; test on publish; closes #2999
  • f49c0ce Fix changelog issues/pr URLs (#3047)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of mocha is breaking the build 🚨

Version 4.0.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.5.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v4.0.0

4.0.0 / 2017-10-02

You might want to read this before filing a new bug! 😝

💥 Breaking Changes

For more info, please read this article.

Compatibility

  • #3016: Drop support for unmaintained versions of Node.js (@boneskull):
    • 0.10.x
    • 0.11.x
    • 0.12.x
    • iojs (any)
    • 5.x.x
  • #2979: Drop support for non-ES5-compliant browsers (@boneskull):
    • IE7
    • IE8
    • PhantomJS 1.x
  • #2615: Drop Bower support; old versions (3.x, etc.) will remain available (@ScottFreeCode, @boneskull)

Default Behavior

  • #2879: By default, Mocha will no longer force the process to exit once all tests complete. This means any test code (or code under test) which would normally prevent node from exiting will do so when run in Mocha. Supply the --exit flag to revert to pre-v4.0.0 behavior (@ScottFreeCode, @boneskull)

Reporter Output

👎 Deprecations

  • #2493: The --compilers command-line option is now soft-deprecated and will emit a warning on STDERR. Read this for more info and workarounds (@ScottFreeCode, @boneskull)

🎉 Enhancements

  • #2628: Allow override of default test suite name in XUnit reporter (@ngeor)

📖 Documentation

🔩 Other

Commits

The new version differs by 48 commits.

  • d69bf14 Release v4.0.0
  • 171b9f9 pfix "prepublishOnly" potential portability problem
  • 60e39d9 Update link to wiki (GitHub at the leading --)
  • 804f9d5 Update link because GitHub ate the leading --
  • 3326c23 update CHANGELOG for v4.0.0 [ci skip]
  • 6dd9252 add link to wiki on --compilers deprecation
  • 96318e1 Deprecate --compilers
  • 92beda9 drop bower support
  • 58a4c6a remove unused .npmignore
  • 7af6611 kill Date#toISOString shim
  • 43501a2 reduce noise about slow tests; make a few tests faster, etc.
  • fa228e9 update --exit / --no-exit integration test for new default behavior
  • 3fdd3ff Switch default from forced exit to no-exit
  • c5d69e0 add integration tests for --exit/--no-exit
  • 3a7f8dc enhance runMochaJSON() helper by returning the subprocess instance

There are 48 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

TypeError: Object #<Object> has no method 'execSync'

Using your first example I get the error: "TypeError: Object # has no method 'execSync'".

Here is my index.js file:

var terminal = require('oh-my-terminal')
var term = terminal.exec('echo hello world');
console.log(term);
[/_/Workspace/gits/wireframer]$ node .scripts/jade.js 

/home/gavin/MEGA/Workspace/gits/wireframer/node_modules/oh-my-terminal/lib/index.coffee:37
          return process.execSync(args.command, args.options);
                         ^
TypeError: Object #<Object> has no method 'execSync'
  at Function.module.exports.Terminal.exec (/home/gavin/MEGA/Workspace/gits/wireframer/node_modules/oh-my-terminal/lib/index.coffee:19:22)
  at Object.<anonymous> (/home/gavin/MEGA/Workspace/gits/wireframer/.scripts/jade.js:28:21)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:929:3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.