forked from microsoft/nodejstools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request microsoft#1143 from mjbvz/typings-wrapper
Create Wrapper Script for Installing Typings
- Loading branch information
Showing
5 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Nodejs/Product/Nodejs/TypingsAcquisitionTool/bin/install_typings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env node | ||
/** | ||
Tool to aquire typings used for NTVS IntelliSense. | ||
This is a simple wrapper around `typings-core`, with the main | ||
difference being that missing packages do not stop other typings | ||
from being aquired. | ||
*/ | ||
"use strict"; | ||
var events = require('events'); | ||
var minimist = require('minimist'); | ||
var typingsTool = require('../index'); | ||
|
||
var argv = minimist(process.argv.slice(2), { | ||
boolean: ['save', 'verbose'], | ||
string: ['cwd'] | ||
}); | ||
|
||
var emitter = new events.EventEmitter(); | ||
|
||
var options = { | ||
save: argv.save, | ||
global: true, | ||
emitter: emitter, | ||
cwd: argv.cwd || process.cwd() | ||
}; | ||
|
||
var packagesToInstall = argv._; | ||
|
||
if (!packagesToInstall.length) { | ||
// top level package install | ||
typingsTool.installTypingsForProject(options) | ||
} else { | ||
typingsTool.runAll(packagesToInstall.map(function (name) { | ||
return typingsTool.installTypingsForPackage(name, options); | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var typings = require('typings-core'); | ||
|
||
/** | ||
* Create a promise that runs one or more promises sequentially. | ||
*/ | ||
module.exports.runAll = function (promises) { | ||
return promises.reduce(function (p1, p2) { | ||
return p1.then(function () { | ||
return p2; | ||
}); | ||
}); | ||
}; | ||
|
||
/** | ||
* Installs the typings for `packageName` with `options`. | ||
*/ | ||
module.exports.installTypingsForPackage = function (packageName, options) { | ||
return typings.installDependenciesRaw(["dt~" + packageName], options) | ||
.then(function () { | ||
console.log("Acquired typings for '" + packageName + "'"); | ||
}) | ||
.catch(function (e) { | ||
console.error("Could not acquire typings for '" + packageName + "'"); | ||
}); | ||
}; | ||
|
||
/** | ||
* Installs the typings for the current project. | ||
*/ | ||
module.exports.installTypingsForProject = function(options) { | ||
return typings.install(options) | ||
.then(function () { | ||
console.log("Acquired typings for project"); | ||
}) | ||
.catch(function (e) { | ||
console.error("Could not acquire typings for project"); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "ntvs-typings-acquisition-tool", | ||
"author": "Microsoft", | ||
"version": "1.0.0", | ||
"description": "Internal tool that aquires typings to power Node.js Tools For Visual Studio IntelliSense", | ||
"license": "Apache 2", | ||
"main": "index.js", | ||
"dependencies": { | ||
"minimist": "1.2.0", | ||
"typings-core": "1.3.1" | ||
}, | ||
"bin": { | ||
"ntvs_install_typings": "./bin/install_typings" | ||
} | ||
} |