Skip to content

Commit

Permalink
Revert "chore: Switch from gulp to gts, TypeScript 2.6 (#173)" (#185)
Browse files Browse the repository at this point in the history
This reverts commit cb9f380 so that
we can move it to a `next` branch and leave `master` releasable.
  • Loading branch information
ofrobots authored Nov 20, 2017
1 parent 8eddbc9 commit 86c4190
Show file tree
Hide file tree
Showing 42 changed files with 1,017 additions and 4,050 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Language: JavaScript
BasedOnStyle: Google
ColumnLimit: 80
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
node_modules/*
build/
/lib/
/test/
types/
.idea
.vscode
docs/
npm-debug.log
coverage
*.js.map
yarn-error.log
**/*.js
yarn-error.log
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ language: node_js
node_js:
- "4"
- "6"
- "8"
- "9"
- "7"

script:
- npm test
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ the following snippet should work.

```js
var google = require('googleapis');
var GoogleAuth = require('google-auth-library').GoogleAuth;
var GoogleAuth = require('google-auth-library');

var authFactory = new GoogleAuth();
var dns = google.dns('v1');
Expand Down
86 changes: 86 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
'use strict';

require('source-map-support').install();

const clangFormat = require('clang-format');
const del = require('del');
const format = require('gulp-clang-format');
const gulp = require('gulp');
const merge = require('merge2');
const mocha = require('gulp-mocha');
const sourcemaps = require('gulp-sourcemaps');
const ts = require('gulp-typescript');
const tslint = require('gulp-tslint');

const outDir = 'build';
const sources = ['ts/lib/**/*.ts'];
const tests = ['ts/test/**/*.ts'];
const allFiles = ['*.js'].concat(sources, tests);

let exitOnError = true;
function onError() {
if (exitOnError) {
process.exit(1);
}
}

gulp.task('test.check-format', () => {
return gulp.src(allFiles)
.pipe(format.checkFormat('file', clangFormat))
.on('warning', onError);
});

gulp.task('format', () => {
return gulp.src(allFiles, {base: '.'})
.pipe(format.format('file', clangFormat))
.pipe(gulp.dest('.'));
});

gulp.task('test.check-lint', () => {
return gulp.src(allFiles)
.pipe(tslint({formatter: 'verbose'}))
.pipe(tslint.report())
.on('warning', onError);
});

gulp.task('clean', () => {
return del([`${outDir}`]);
});

gulp.task('compile', () => {
const tsResult = gulp.src(sources)
.pipe(sourcemaps.init())
.pipe(ts.createProject('tsconfig.json')())
.on('error', onError);
return merge([
tsResult.dts.pipe(gulp.dest(`${outDir}/definitions`)),
tsResult.js
.pipe(sourcemaps.write(
'.', {includeContent: false, sourceRoot: '../../src'}))
.pipe(gulp.dest(`${outDir}/src`)),
tsResult.js.pipe(gulp.dest(`${outDir}/src`))
]);
});

gulp.task('test.compile', ['compile'], () => {
return gulp.src(tests, {base: '.'})
.pipe(sourcemaps.init())
.pipe(ts.createProject('tsconfig.json')())
.on('error', onError)
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: '../..'}))
.pipe(gulp.dest(`${outDir}/`));
});

gulp.task('test.unit', ['test.compile'], () => {
return gulp.src([`${outDir}/test/**/*.js`]).pipe(mocha({verbose: true}));
});

gulp.task('watch', () => {
exitOnError = false;
gulp.start(['test.compile']);
// TODO: also run unit tests in a non-fatal way
return gulp.watch(allFiles, ['test.compile']);
});

gulp.task('test', ['test.unit', 'test.check-format', 'test.check-lint']);
gulp.task('default', ['compile']);
Loading

0 comments on commit 86c4190

Please sign in to comment.