Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 999bf07

Browse files
committed
feat(typescript): adding typescript to protractor
Converting a 3 files over to typescript. Adding an `npm prepublish` step that will use gulp to download the typings, transpile the files with tscto the built/ directory and copy the rest of the javascript files from lib/ to the built/ folder. Also adding scripts to package.json for `npm run tsc` and `npm run tsc:w` for transpiling help.
1 parent a7734f8 commit 999bf07

28 files changed

+453
-395
lines changed

.clang-format

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Language: JavaScript
2+
BasedOnStyle: Google
3+
ColumnLimit: 80

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ xmloutput*
1212
npm-debug.log
1313

1414
*.swp
15+
16+
typings/
17+
built/

gulpfile.js

+45-25
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,59 @@
11
'use strict';
22

33
var gulp = require('gulp');
4+
var clangFormat = require('clang-format');
5+
var gulpFormat = require('gulp-clang-format');
46
var runSequence = require('run-sequence');
5-
var spawnSync = require('child_process').spawnSync;
7+
var spawn = require('child_process').spawn;
8+
9+
var runSpawn = function(done, task, opt_arg) {
10+
var child = spawn(task, opt_arg);
11+
child.stdout.on('data', function(data) {
12+
console.log(data.toString());
13+
});
14+
child.stderr.on('data', (data) => {
15+
console.log(data.toString());
16+
});
17+
child.on('close', function(code) {
18+
done();
19+
});
20+
}
621

722
gulp.task('built:copy', function() {
8-
var srcFiles = ['lib/**/*'];
9-
var dist = 'built/';
10-
return gulp.src(srcFiles).pipe(gulp.dest(dist));
23+
return gulp.src(['lib/**/*','!lib/**/*.ts'])
24+
.pipe(gulp.dest('built/'));
25+
});
26+
27+
gulp.task('webdriver:update', function(done) {
28+
runSpawn(done, 'bin/webdriver-manager', ['update']);
29+
});
30+
31+
gulp.task('jslint', function(done) {
32+
runSpawn(done, './node_modules/.bin/jshint', ['lib','spec', 'scripts']);
33+
});
34+
35+
gulp.task('clang', function(done) {
36+
return gulp.src(['lib/**/*.ts'])
37+
.pipe(gulpFormat.checkFormat('file', clangFormat))
38+
.on('warning', function(e) {
39+
console.log(e);
40+
});
41+
done();
42+
});
43+
44+
gulp.task('typings', function(done) {
45+
runSpawn(done, 'node_modules/.bin/typings', ['install']);
1146
});
1247

13-
gulp.task('webdriver:update', function() {
14-
var child = spawnSync('bin/webdriver-manager', ['update']);
15-
if (child.stdout != null) {
16-
console.log(child.stdout.toString());
17-
}
18-
if (child.status !== 0) {
19-
throw new Error('webdriver-manager update: child error');
20-
}
48+
gulp.task('tsc', function(done) {
49+
runSpawn(done, 'node_modules/typescript/bin/tsc');
2150
});
2251

23-
gulp.task('jslint', function() {
24-
var child = spawnSync('./node_modules/.bin/jshint', ['lib','spec', 'scripts']);
25-
if (child != null && child.stdout != null ) {
26-
console.log(child.stdout.toString());
27-
}
28-
if (child.status !== 0) {
29-
throw new Error('jslint: child error');
30-
}
52+
gulp.task('prepublish', function(done) {
53+
runSequence(['typings', 'jslint', 'clang'],'tsc', 'built:copy', done);
3154
});
3255

33-
gulp.task('pretest', function() {
56+
gulp.task('pretest', function(done) {
3457
runSequence(
35-
['webdriver:update', 'jslint'],
36-
'built:copy'
37-
);
58+
['webdriver:update', 'typings', 'jslint', 'clang'], 'tsc', 'built:copy', done);
3859
});
39-
gulp.task('prepublish', ['built:copy']);

lib/configParser.js

-232
This file was deleted.

0 commit comments

Comments
 (0)