npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jim.catts/run-script-os

v1.1.4

Published

run-script-os is a tool that will let you use generic npm script commands that will pass through to os specific commands.

Downloads

33

Readme

Why does this fork exists?

This fork was made to fix #20 in the original repo. Please check in there if you want to have a well supported version. There's also a couple of changes that were implemented to improve the readibility and allow for easier fixes in the future, I sure hope @charlesguse don't mind too much!

run-script-os

You will be able to use OS specific operations in npm scripts.

Who would want this?

If you have experienced the pain of trying to make npm scripts usable across different operating system, this package is for you! Looking at you rm and del!

Installation

npm install --save-dev run-script-os

Usage

Set run-script-os (or run-os) as the value of the npm script field that you want different functionality per OS. In the example below, we set test, but it can be any npm script. It also uses pre and post commands (explained more below).

Then create OS specific scripts. In the example below, you can see:

  • test:win32
  • test:linux:darwin
  • test:default

Those can have OS specific logic.

package.json

{
  ...
  "scripts": {
    ...
    "test": "run-script-os",
    "test:win32": "echo 'del whatever you want in Windows 32/64'",
    "test:darwin:linux": "echo 'You can combine OS tags and rm all the things!'",
    "test:default": "echo 'This will run on any platform that does not have its own script'"
    ...
  },
  ...
}

Windows Output:

> npm test
del whatever you want in Windows 32/64

macOS and Linux Output:

> npm test
You can combine OS tags and rm all the things!

Aliases

You can use the following aliases:

  • :windows - Alias for win32
  • :macos - Alias for darwin
  • :nix - This will run on anything considered to be a *nix OS (aix, darwin, freebsd, linux, openbsd, sunos, android)
  • :default - This will run if no platform-specific scripts are found

Override detection settings for linux-based shells on Windows

By default, run-script-os will detect cygwin/git bash as Windows. If you would rather your platform be detected as Linux under these environments:

Set environment variable:

RUN_OS_WINBASH_IS_LINUX=true

NPM Scripts Order

When you call a script like npm test, npm will first call pretest if it exists. It will then call test, which, if you are using run-script-os, it will then call npm run test:YOUR OS, which in turn will call pretest:YOUR OS before actually running test:YOUR OS. Then posttest:YOUR OS will run, and then after that posttest will finally execute.

There is an example showing pre and post commands found in the package.json of this repository.

OS Options: darwin, freebsd, linux, sunos, win32

More information can be found in Node's process.platform and Node's os.platform().