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

Commit 8ee9583

Browse files
Initial gulpfile that only maps src.ts to src (#281)
PR-URL: #281
1 parent 4bf7b8f commit 8ee9583

22 files changed

+1509
-100
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ coverage
33
npm-debug.log
44
.DS_Store
55
.vscode
6+
src

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ node_js:
55
- '6'
66
- '8'
77
script:
8-
- ./bin/run-test.sh -c
8+
- npm run build && ./bin/run-test.sh -c
99
notifications:
1010
email:
1111

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ install:
1818
# Post-install test scripts.
1919
test_script:
2020
# run tests
21-
- ps: node_modules/.bin/mocha test --timeout 4000 --R
21+
- ps: npm run build ; node_modules/.bin/mocha test --timeout 4000 --R
2222

2323
# Don't actually build using MSBuild
2424
build: off

bin/run-test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ while true; do
1919
done
2020

2121
# Lint
22-
$(npm bin)/jshint . || exit 1
22+
# TODO: Re-enable this when the transition to Typescript is complete
23+
# $(npm bin)/jshint . || exit 1
2324

2425
# Get test/coverage command
2526
counter=0

gulpfile.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright 2017 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
'use strict';
17+
18+
require('source-map-support').install();
19+
20+
const del = require('del');
21+
const gulp = require('gulp');
22+
const merge = require('merge2');
23+
const sourcemaps = require('gulp-sourcemaps');
24+
const spawn = require('child_process').spawn;
25+
const ts = require('gulp-typescript');
26+
const path = require('path');
27+
const process = require('process');
28+
29+
const tsconfigPath = path.join(__dirname, 'tsconfig.json');
30+
const outDir = '.';
31+
const sources = ['src.ts/**/*.ts', 'src.ts/**/*.js'];
32+
33+
let exitOnError = true;
34+
function onError() {
35+
if (exitOnError) {
36+
process.exit(1);
37+
}
38+
}
39+
40+
gulp.task('clean', () => {
41+
return del(['src']);
42+
});
43+
44+
gulp.task('compile', () => {
45+
const tsResult = gulp.src(sources)
46+
.pipe(sourcemaps.init())
47+
.pipe(ts.createProject(tsconfigPath)())
48+
.on('error', onError);
49+
return merge([
50+
tsResult.dts.pipe(gulp.dest(`${outDir}/definitions`)),
51+
tsResult.js
52+
.pipe(sourcemaps.write(
53+
'.', {includeContent: false, sourceRoot: '../../src'}))
54+
.pipe(gulp.dest(`${outDir}/src`)),
55+
tsResult.js.pipe(gulp.dest(`${outDir}/src`))
56+
]);
57+
});
58+
59+
gulp.task('test.unit', ['compile'], cb => {
60+
spawn('bash', ['./bin/run-test.sh'], {
61+
stdio : 'inherit'
62+
}).on('close', cb);
63+
});
64+
65+
gulp.task('test', ['test.unit']);
66+
gulp.task('default', ['compile']);

package.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@
2424
"changelog-maker": "^2.2.2",
2525
"closure-npc": "*",
2626
"coveralls": "^2.11.2",
27+
"del": "^2.2.2",
2728
"extend": "^3.0.0",
29+
"gulp": "^3.9.1",
30+
"gulp-clang-format": "^1.0.23",
31+
"gulp-sourcemaps": "^2.6.0",
32+
"gulp-tslint": "^8.0.0",
33+
"gulp-typescript": "^3.1.6",
2834
"istanbul": "^0.4.1",
2935
"jshint": "^2.7.0",
36+
"merge2": "^1.0.3",
3037
"mocha": "^3.0.0",
3138
"nock": "^9.0.0",
3239
"proxyquire": "^1.7.11",
33-
"request": "^2.81.0"
40+
"request": "^2.81.0",
41+
"source-map-support": "^0.4.15",
42+
"typescript": "^2.3.2"
3443
},
3544
"dependencies": {
3645
"@google-cloud/common": "^0.13.3",
@@ -45,11 +54,12 @@
4554
"split": "^1.0.0"
4655
},
4756
"scripts": {
48-
"test": "./bin/run-test.sh",
49-
"system-test": "./bin/run-system-test.sh",
50-
"changelog": "./bin/run-changelog.sh",
51-
"coverage": "./bin/run-test.sh -c",
52-
"bump": "./bin/run-bump.sh",
53-
"closure": "./node_modules/.bin/closure-npc"
57+
"build": "gulp",
58+
"test": "gulp test",
59+
"system-test": "gulp && ./bin/run-system-test.sh",
60+
"changelog": "gulp && ./bin/run-changelog.sh",
61+
"coverage": "gulp && ./bin/run-test.sh -c",
62+
"bump": "gulp && ./bin/run-bump.sh",
63+
"closure": "gulp && ./node_modules/.bin/closure-npc"
5464
}
5565
}

0 commit comments

Comments
 (0)