Skip to content

Add ability to "jake link-vs" & "jake unlink-vs" which adds/removes symlink #1335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 74 additions & 4 deletions Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var fs = require("fs");
var path = require("path");
var child_process = require("child_process");
var utils = require("./scripts/task-utils");

// Variables
var compilerDirectory = "src/compiler/";
Expand Down Expand Up @@ -351,7 +352,7 @@ desc("Builds the test infrastructure using the built compiler");
task("tests", ["local", run].concat(libraryTargets));

function exec(cmd, completeHandler) {
var ex = jake.createExec([cmd]);
var ex = jake.createExec(cmd, {windowsVerbatimArguments: true});
// Add listeners for output and error
ex.addListener("stdout", function(output) {
process.stdout.write(output);
Expand Down Expand Up @@ -473,18 +474,17 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
exec(cmd);
}, {async: true});


// Baseline Diff
desc("Diffs the compiler baselines using the diff tool specified by the %DIFF% environment variable");
task('diff', function () {
var cmd = "%DIFF% " + refBaseline + ' ' + localBaseline;
var cmd = '"' + utils.getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
console.log(cmd)
exec(cmd);
}, {async: true});

desc("Diffs the RWC baselines using the diff tool specified by the %DIFF% environment variable");
task('diff-rwc', function () {
var cmd = "%DIFF% " + refRwcBaseline + ' ' + localRwcBaseline;
var cmd = '"' + utils.getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
console.log(cmd)
exec(cmd);
}, {async: true});
Expand Down Expand Up @@ -571,3 +571,73 @@ task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function
});
ex.run();
}, { async: true });

desc("** use at your own risk, not supported ** Tasks & extensions by the community.");
task('---------- community ----------', function() {
});

var tscPath = path.join(__dirname, tscFile)
var libPath = path.join(path.dirname(tscPath), 'lib.d.ts')
var servicesPath = path.join(__dirname, servicesFile)

desc("Link Visual Studio to this built version of TypeScript");
task('link-vs', [servicesFile, tscFile], function() {

utils.checkAdmin(function(){
var paths = utils.findTsPathsOfVS();
var ext = utils.getOriginalExt();

if( !fs.existsSync(paths['tsc'] + ext) ) {
fs.renameSync(paths['tsc'], paths['tsc'] + ext)
fs.renameSync(paths['tsc.lib.d'], paths['tsc.lib.d'] + ext)
}
if( !fs.existsSync(paths['services'] + ext) ) {
fs.renameSync(paths['services'], paths['services'] + ext)
fs.renameSync(paths['services.lib.d'], paths['services.lib.d'] + ext)
}

// Unlink paths
utils.unlinkPaths(paths)

// Create symlinks, does Visual Studio pick up the changes? Force a refresh?
fs.symlinkSync(tscPath, paths['tsc'])
fs.symlinkSync(libPath, paths['tsc.lib.d'])
fs.symlinkSync(servicesPath, paths['services'])
fs.symlinkSync(libPath, paths['services.lib.d'])

console.log('Done!')
complete();
});


}, { async: true });

desc("Unlink/restore Visual Studio to original version of TypeScript");
task('unlink-vs', [servicesFile, tscFile], function() {

utils.checkAdmin(function(){
var paths = utils.findTsPathsOfVS();
var ext = utils.getOriginalExt();

var errors = []
if( !fs.existsSync(paths['tsc'] + ext) ) {
errors.push("Original tsc not found at "+ (paths['tsc'] + ext))
}
if( !fs.existsSync(paths['services'] + ext) ) {
errors.push("Original Services not found at "+ (paths['services'] + ext))
}
if(errors.length)
throw new Error("Missing files\n" + errors.join("\n"))

utils.unlinkPaths(paths)

fs.renameSync(paths['tsc'] + ext, paths['tsc'])
fs.renameSync(paths['tsc.lib.d'] + ext, paths['tsc.lib.d'])
fs.renameSync(paths['services'] + ext, paths['services'])
fs.renameSync(paths['services.lib.d'] + ext, paths['services.lib.d'])

console.log('Done!')
complete();
});

}, { async: true });
Loading