npm-root-g

1.0.1 • Public • Published

npm-root-g

get the result or the cached result, of cmd 'npm root -g'.

Install

npm install npm-root-g

Usage & Api

var npm_root_g = require("npm-root-g");

var tm0 = (new Date()).getTime();

//npm_root_g (cb [, refresh] )
npm_root_g(		//execute the cmd at the 1st time
	function (err, data1) {
		var tm1 = (new Date()).getTime();

		console.log(data1);
		console.log("tm=" + (tm1 - tm0));

		npm_root_g(		//get the cached result after the 1st time, except the 'refresh' is set true.
			function (err, data2) {
				var tm2 = (new Date()).getTime();

				console.log(data2);
				console.log("tm=" + (tm2 - tm1));

				done(!(
					data1 === data2 &&
					(tm1 - tm0) > (tm2 - tm1)
				));
			}
		);

	}
);


Readme

Keywords

Package Sidebar

Install

npm i npm-root-g

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

2.93 kB

Total Files

4

Last publish

Collaborators

  • adf0001