Skip to content

mainmatter/who-ran-me

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

who-ran-me

This is a tiny utility function that is designed to tell you how the current node script has been run. For example if you have a test file that looks like this:

const whoRanMe = require('who-ran-me');

describe('who-ran-me utility', function () {
  it('should always just log who ran me!', function () {
    console.log(`Run with ${whoRanMe()}`);
  });
});

And the following scripts entries in your package.json:

{
  "scripts": {
    "test": "mocha"
  }
}

you would have multiple ways to actually execute this test and it will print out the method:

npm test
# Run with npm
yarn test
# Run with yarn
# mocha is installed globally
mocha
# Run with mocha
# mocha does not need to be installed globally
npx mocha
# Run with npx

About

Small utillity to check if script was run with npm or yarn

Resources

Stars

Watchers

Forks

Packages

No packages published