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

Commit 9608201

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 9608201

26 files changed

+434
-385
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

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ built/
22
node_modules/
33
selenium/
44
testapp/inbrowsertest/
5+
typings/
56
website/bower_components/
67
website/build/
78
website/docgen/build/

gulpfile.js

+38-25
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,52 @@
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, {stdio: 'inherit'});
11+
child.on('close', function() {
12+
done();
13+
});
14+
};
615

716
gulp.task('built:copy', function() {
8-
var srcFiles = ['lib/**/*'];
9-
var dist = 'built/';
10-
return gulp.src(srcFiles).pipe(gulp.dest(dist));
17+
return gulp.src(['lib/**/*','!lib/**/*.ts'])
18+
.pipe(gulp.dest('built/'));
19+
});
20+
21+
gulp.task('webdriver:update', function(done) {
22+
runSpawn(done, 'bin/webdriver-manager', ['update']);
23+
});
24+
25+
gulp.task('jslint', function(done) {
26+
runSpawn(done, './node_modules/.bin/jshint', ['lib','spec', 'scripts']);
27+
});
28+
29+
gulp.task('clang', function() {
30+
return gulp.src(['lib/**/*.ts'])
31+
.pipe(gulpFormat.checkFormat('file', clangFormat))
32+
.on('warning', function(e) {
33+
console.log(e);
34+
});
35+
});
36+
37+
gulp.task('typings', function(done) {
38+
runSpawn(done, 'node_modules/.bin/typings', ['install']);
1139
});
1240

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-
}
41+
gulp.task('tsc', function(done) {
42+
runSpawn(done, 'node_modules/typescript/bin/tsc');
2143
});
2244

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-
}
45+
gulp.task('prepublish', function(done) {
46+
runSequence(['typings', 'jslint', 'clang'],'tsc', 'built:copy', done);
3147
});
3248

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

lib/configParser.js

-232
This file was deleted.

0 commit comments

Comments
 (0)