tfs
Version:
NodeJS wrapper for Team Foundation Source Control CLI.
190 lines (150 loc) • 7.28 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: setup.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: setup.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>var output = require('./utils/output'),
fileExists = require('./utils/fileExists'),
fs = require('fs'),
settingsPath = __dirname + '/../config/settings.json';
module.exports = setup;
/**
* Get TFS settings (after starting setting up if they don't exist yet)
*
* @version 1.3.0
*
* @return {object} Settings
*/
function setup() {
if (!fileExists(settingsPath)) {
buildSettings();
}
var settings = fs.readFileSync(settingsPath, 'utf8');
settings = JSON.parse(settings);
if (!settings.tfPath || !settings.vsArchitecture || !settings.vsVersion) {
buildSettings();
}
// Rebuild settings if TF.exe has been uninstalled/updated
if (!fileExists(settings.tfPath)) {
buildSettings();
}
return settings;
}
/**
* Look for TFS command line tool and create settings file
*/
function buildSettings() {
var pf32Path = process.env['ProgramFiles(x86)'],
pf64Path = process.env.ProgramFiles,
settings,
tfPath = '/Common7/IDE/TF.exe';
switch (true) {
case fileExists(pf64Path + '/Microsoft Visual Studio 14.0' + tfPath):
settings = {
tfPath: pf64Path + '/Microsoft Visual Studio 14.0' + tfPath,
vsArchitecture: 64,
vsVersion: 2015
};
break;
case fileExists(pf32Path + '/Microsoft Visual Studio 14.0' + tfPath):
settings = {
tfPath: pf32Path + '/Microsoft Visual Studio 14.0' + tfPath,
vsArchitecture: 32,
vsVersion: 2015
};
break;
case fileExists(pf64Path + '/Microsoft Visual Studio 12.0' + tfPath):
settings = {
tfPath: pf64Path + '/Microsoft Visual Studio 12.0' + tfPath,
vsArchitecture: 64,
vsVersion: 2013
};
break;
case fileExists(pf32Path + '/Microsoft Visual Studio 12.0' + tfPath):
settings = {
tfPath: pf32Path + '/Microsoft Visual Studio 12.0' + tfPath,
vsArchitecture: 32,
vsVersion: 2013
};
break;
case fileExists(pf64Path + '/Microsoft Visual Studio 11.0' + tfPath):
settings = {
tfPath: pf64Path + '/Microsoft Visual Studio 11.0' + tfPath,
vsArchitecture: 64,
vsVersion: 2012
};
break;
case fileExists(pf32Path + '/Microsoft Visual Studio 11.0' + tfPath):
settings = {
tfPath: pf32Path + '/Microsoft Visual Studio 11.0' + tfPath,
vsArchitecture: 32,
vsVersion: 2012
};
break;
case fileExists(pf64Path + '/Microsoft Visual Studio 10.0' + tfPath):
settings = {
tfPath: pf64Path + '/Microsoft Visual Studio 10.0' + tfPath,
vsArchitecture: 64,
vsVersion: 2010
};
break;
case fileExists(pf32Path + '/Microsoft Visual Studio 10.0' + tfPath):
settings = {
tfPath: pf32Path + '/Microsoft Visual Studio 10.0' + tfPath,
vsArchitecture: 32,
vsVersion: 2010
};
break;
case fileExists(pf64Path + '/Microsoft Visual Studio 9.0' + tfPath):
settings = {
tfPath: pf64Path + '/Microsoft Visual Studio 9.0' + tfPath,
vsArchitecture: 64,
vsVersion: 2008
};
break;
case fileExists(pf32Path + '/Microsoft Visual Studio 9.0' + tfPath):
settings = {
tfPath: pf32Path + '/Microsoft Visual Studio 9.0' + tfPath,
vsArchitecture: 32,
vsVersion: 2008
};
break;
case fileExists(__dirname + '/../test/.mock'):
settings = {};
break;
default:
output.error('Impossible to find you TF.exe');
break;
}
output.info('Writing ' + settingsPath);
var fileSource = JSON.stringify(settings, null, 2);
fs.writeFileSync(settingsPath, fileSource, 'utf8');
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-TFS%2520Add.html">TFS Add</a></li><li><a href="module-TFS%2520Checkin.html">TFS Checkin</a></li><li><a href="module-TFS%2520Checkout.html">TFS Checkout</a></li><li><a href="module-TFS%2520Get.html">TFS Get</a></li><li><a href="module-TFS%2520History.html">TFS History</a></li><li><a href="module-TFS%2520Info.html">TFS Info</a></li><li><a href="module-TFS%2520Status.html">TFS Status</a></li><li><a href="module-TFS%2520Undo.html">TFS Undo</a></li><li><a href="module-Utilities%2520Camelize.html">Utilities Camelize</a></li><li><a href="module-Utilities%2520Format.html">Utilities Format</a></li></ul><h3>Global</h3><ul><li><a href="global.html#_delete">_delete</a></li><li><a href="global.html#branch">branch</a></li><li><a href="global.html#branches">branches</a></li><li><a href="global.html#buildSettings">buildSettings</a></li><li><a href="global.html#changeset">changeset</a></li><li><a href="global.html#configure">configure</a></li><li><a href="global.html#debug">debug</a></li><li><a href="global.html#destroy">destroy</a></li><li><a href="global.html#diff">diff</a></li><li><a href="global.html#dir">dir</a></li><li><a href="global.html#fileExists">fileExists</a></li><li><a href="global.html#folderdiff">folderdiff</a></li><li><a href="global.html#format">format</a></li><li><a href="global.html#label">label</a></li><li><a href="global.html#labels">labels</a></li><li><a href="global.html#localversions">localversions</a></li><li><a href="global.html#lock">lock</a></li><li><a href="global.html#merge">merge</a></li><li><a href="global.html#merges">merges</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#permission">permission</a></li><li><a href="global.html#rename">rename</a></li><li><a href="global.html#resolve">resolve</a></li><li><a href="global.html#rollback">rollback</a></li><li><a href="global.html#setup">setup</a></li><li><a href="global.html#shelve">shelve</a></li><li><a href="global.html#shelvesets">shelvesets</a></li><li><a href="global.html#tf">tf</a></li><li><a href="global.html#tfs">tfs</a></li><li><a href="global.html#undelete">undelete</a></li><li><a href="global.html#unlabel">unlabel</a></li><li><a href="global.html#unshelve">unshelve</a></li><li><a href="global.html#view">view</a></li><li><a href="global.html#workfold">workfold</a></li><li><a href="global.html#workspace">workspace</a></li><li><a href="global.html#workspaces">workspaces</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Sun Mar 06 2016 00:07:41 GMT+0100 (Romance Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>