Skip to content

Commit 75eaaf7

Browse files
typings + engineering work for node api
1 parent f29b767 commit 75eaaf7

40 files changed

+533
-4126
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Build
22
_build
3+
_test
34

45
# Logs
56
logs
File renamed without changes.
File renamed without changes.

node/docs/structure.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"Execution": {
1515
"Summary": "Tasks typically execute a series of tools (cli) and set the result of the task based on the outcome of those",
16-
"Sample": "samples/toolrunner.ts",
16+
"Sample": "samples/toolrunner.src",
1717
"Document": [
1818
"task.createToolRunner",
1919
"toolrunner.ToolRunner.arg",
@@ -54,7 +54,7 @@
5454
},
5555
"Localization": {
5656
"Summary": "Localization is optional but is supported using these functions at runtime",
57-
"Sample": "samples/loc.ts",
57+
"Sample": "samples/loc.src",
5858
"Document": [
5959
"task.setResourcePath",
6060
"task.loc"
File renamed without changes.

node/gulpfile.js

Lines changed: 0 additions & 133 deletions
This file was deleted.

node/make.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
require('shelljs/make');
3+
var path = require('path');
4+
var fs = require('fs');
5+
6+
var rp = function (relPath) {
7+
return path.join(__dirname, relPath);
8+
}
9+
10+
var buildPath = path.join(__dirname, '_build');
11+
var testPath = path.join(__dirname, '_test');
12+
13+
var run = function(cl) {
14+
console.log('> ' + cl);
15+
var rc = exec(cl).code;
16+
if (rc !== 0) {
17+
echo('Exec failed with rc ' + rc);
18+
exit(rc);
19+
}
20+
}
21+
22+
target.clean = function () {
23+
rm('-Rf', buildPath);
24+
};
25+
26+
target.build = function() {
27+
target.clean();
28+
29+
run('tsc --outDir ' + buildPath);
30+
cp('-Rf', rp('typings'), buildPath);
31+
cp(rp('package.json'), buildPath);
32+
cp(rp('lib.json'), buildPath);
33+
cp('-Rf', rp('Strings'), buildPath);
34+
35+
target.loc();
36+
}
37+
38+
target.test = function() {
39+
target.build();
40+
41+
run('tsc --outDir ' + testPath + ' test/tasklib.ts');
42+
cp('-Rf', rp('test/scripts'), testPath);
43+
run('mocha ' + path.join(testPath, 'tasklib.js'));
44+
}
45+
46+
target.loc = function() {
47+
var lib = require('./lib.json');
48+
var strPath = path.join('Strings', 'resources.resjson', 'en-US')
49+
mkdir('-p', strPath);
50+
var strings = { };
51+
if (lib.messages) {
52+
for (var key in lib.messages) {
53+
strings['loc.messages.' + key] = lib.messages[key];
54+
}
55+
}
56+
57+
// Create the en-US resjson file.
58+
var enContents = JSON.stringify(strings, null, 2);
59+
fs.writeFileSync(path.join(strPath, 'resources.resjson'), enContents)
60+
}

node/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "vsts-task-lib",
3-
"version": "0.8.4",
3+
"version": "0.9.0",
44
"description": "VSTS Task SDK",
55
"main": "./task.js",
6+
"typings": "./task.d.ts",
67
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8+
"test": "node make.js test"
89
},
910
"repository": {
1011
"type": "git",
@@ -33,7 +34,7 @@
3334
},
3435
"devDependencies": {
3536
"del": "^1.2.0",
36-
"dts-generator": "1.5.0",
37+
"dts-generator": "^1.7.0",
3738
"gulp": "^3.9.0",
3839
"gulp-mocha": "2.0.0",
3940
"gulp-typescript": "^2.9.0",

node/lib/task.ts renamed to node/task.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../typings/main.d.ts" />
1+
/// <reference path="typings/index.d.ts" />
22

33
import Q = require('q');
44
import shell = require('shelljs');
@@ -910,6 +910,10 @@ export function globFirst(pattern: string): string {
910910
export function exec(tool: string, args: any, options?: trm.IExecOptions): Q.Promise<number> {
911911
var toolPath = which(tool, true);
912912
var tr = createToolRunner(toolPath);
913+
tr.on('debug', (data) => {
914+
debug(data);
915+
});
916+
913917
if (args) {
914918
if (args instanceof Array) {
915919
tr.arg(args);
@@ -935,6 +939,10 @@ export function exec(tool: string, args: any, options?: trm.IExecOptions): Q.Pro
935939
export function execSync(tool: string, args: string | string[], options?: trm.IExecOptions): trm.IExecResult {
936940
var toolPath = which(tool, true);
937941
var tr = createToolRunner(toolPath);
942+
tr.on('debug', (data) => {
943+
debug(data);
944+
});
945+
938946
if (args) {
939947
if (args instanceof Array) {
940948
tr.arg(args);
@@ -1072,7 +1080,6 @@ export class CodeCoverageEnabler {
10721080
exports.TaskCommand = tcm.TaskCommand;
10731081
exports.commandFromString = tcm.commandFromString;
10741082
exports.ToolRunner = trm.ToolRunner;
1075-
trm.debug = debug;
10761083

10771084
//-----------------------------------------------------
10781085
// Validation Checks
File renamed without changes.

0 commit comments

Comments
 (0)