aboutsummaryrefslogtreecommitdiffstats
path: root/build/tasks/install_jsdom.js
blob: 73142b654630280d383d71b442e25778cd35d392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module.exports = function( grunt ) {
	grunt.registerTask( "jsdom", function() {
		var current,
			pkg = grunt.config( "pkg" ),
			version = pkg.jsdomVersions[

				// Unfortunately, this is currently the only
				// way to tell the difference between Node and iojs
				/^v0/.test( process.version ) ? "node" : "iojs"
			];

		try {
			current = require( "jsdom/package.json" ).version;
			if ( current === version ) {
				return;
			}
		} catch ( e ) {}

		// Use npm on the command-line
		// There is no local npm
		grunt.util.spawn( {
			cmd: "npm",
			args: [ "install", "jsdom@" + version ],
			opts: { stdio: "inherit" }
		}, this.async() );
	} );
};