GithubHelp home page GithubHelp logo

shelljs-plugin-sleep's Introduction

shelljs-plugin-sleep

GitHub Actions npm shelljs-plugin

A ShellJS plugin for the sleep() command.

Installation

$ npm install --save shelljs
$ npm install --save shelljs-plugin-sleep

Usage

To use this plugin in your project, include it like so:

var shell = require('shelljs');
require('shelljs-plugin-sleep');

// Ex. usage:
shell.sleep(1); // the plugin is now available!

sleep(seconds)

No available options.

Examples:

shell.sleep(3); // sleep for 3000 milliseconds

Supported systems

  • Linux (all variants)
  • OS X
  • Windows

This is only supported for Node v4+

Writing plugins

If you're interested in taking a look at the current state of the plugin API, take a look at index.js. This has helpful comments explaining the necessary boilerplate for writing a plugin. For an example usage of the plugin, take a look at test/test.js.

shelljs-plugin-sleep's People

Contributors

nfischer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shelljs-plugin-sleep's Issues

Issues list Lint broken on node v4

Node version (or tell us if you're using electron or some other framework)

v4

ShellJS version (the most recent version/GitHub branch you see the bug on)

happening on GitHub Actions CI

Operating system

all

Description of the bug:

/home/runner/work/shelljs-plugin-sleep/shelljs-plugin-sleep/node_modules/eslint/node_modules/optionator/node_modules/word-wrap/index.js:9
  let lastCharPos = str.length - 1;
  ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:[37](https://github.com/nfischer/shelljs-plugin-sleep/actions/runs/7125011126/job/19400187643?pr=17#step:5:38)3:25)
    at Object.Module._extensions..js (module.js:[41](https://github.com/nfischer/shelljs-plugin-sleep/actions/runs/7125011126/job/19400187643?pr=17#step:5:42)6:10)
    at Module.load (module.js:3[43](https://github.com/nfischer/shelljs-plugin-sleep/actions/runs/7125011126/job/19400187643?pr=17#step:5:44):32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/runner/work/shelljs-plugin-sleep/shelljs-plugin-sleep/node_modules/eslint/node_modules/optionator/lib/help.js:6:14)
    at Object.<anonymous> (/home/runner/work/shelljs-plugin-sleep/shelljs-plugin-sleep/node_modules/eslint/node_modules/optionator/lib/help.js:260:4)

https://github.com/nfischer/shelljs-plugin-sleep/actions/runs/7125011126/job/19400187643?pr=17

It looks like one of our dependencies is no longer v4-compatible.

Example ShellJS command to reproduce the error:

npm run lint

Test failure on node v4

This appears to be a Mac-only failure: https://github.com/nfischer/shelljs-plugin-sleep/actions/runs/7125313387/job/19401029921?pr=19

  1) plugin-sleep
npm ERR! npm  v2.15.11
       fallback methods
npm ERR! code ELIFECYCLE
         can rely on execSync + helper script:
npm ERR! [email protected] test-without-lint: `mocha`
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/shelljs-plugin-sleep/shelljs-plugin-sleep/test/test.js)
npm ERR! Exit status 1

Error when using a `node` path with spaces in Windows

Node version (or tell us if you're using electron or some other framework):

16.13.2

ShellJS version (the most recent version/GitHub branch you see the bug on):

0.8.5

Operating system:

Windows

Description of the bug:

node path with spaces (C:\Program Files\nodejs\node.exe) doesn't seem to be supported in Windows

C:\path_to_my_project\api> node ./start.cjs
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\path_to_my_project\node_modules\shelljs\src\common.js:399
        throw e;
        ^

Error [ShellJSInternalError]: Command failed: C:\Program Files\nodejs\node.exe C:\path_to_my_project\node_modules\shelljs-plugin-sleep\sleepHelper.js 10
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

    at checkExecSyncError (node:child_process:826:11)
    at Object.execSync (node:child_process:900:15)
    at execSleep (C:\path_to_my_project\node_modules\shelljs-plugin-sleep\index.js:12:11)
    at Object.sleepImpl (C:\path_to_my_project\node_modules\shelljs-plugin-sleep\index.js:34:3)
    at Object.sleep (C:\path_to_my_project\node_modules\shelljs\src\common.js:384:25)
    at Object.<anonymous> (C:\path_to_my_project\api\start.cjs:7:7)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {

Example ShellJS command to reproduce the error:

shell.sleep(1);

Better fallback approach

A better fallback approach might be something like this:

// inside index.js
function sleep(time) {
  child_process.execFileSync(pathToSleepHelper, [time.toString()]);
}

// sleepHelper.js
#!/usr/bin/env node
var time = parseInt(process.argv[2], 10) * 1000;
setTimeout(process.exit, time);

I still need to verify that this does not use any CPU while waiting. If so, then this will work on node v0.11+, without native extensions (it just has to launch a separate process). However, this approach would probably be suitable for including this in ShellJS core.

Input redirection error on Windows

On Win 10 x64.

using versions:

node 7.4.0
npm 4.5.0
"shelljs": "0.7.7",
shelljs-plugin-sleep": "0.1.0",

Trying to do:

var shell = require('shelljs');
require('shelljs-plugin-sleep');
shell.sleep(5);

called via npm as a script.
It works fine on macOS 10.12.* but fails on Win 10 x64 with error:

ERROR: Input redirection is not supported, exiting the process immediately.
ShellJS: internal error
Error: Command failed: timeout 5
ERROR: Input redirection is not supported, exiting the process immediately.

    at checkExecSyncError (child_process.js:490:13)
    at Object.execSync (child_process.js:530:13)
    at Object.execSleep [as sleep] (<repo>\node_modules\shelljs-plugin-sleep\index.js:8:11)
    at Object.sleepImpl (<repo>\node_modules\shelljs-plugin-sleep\index.js:35:9)
    at Object.sleep <repo>\node_modules\shelljs\src\common.js:383:25)

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.