This repository was archived by the owner on Jul 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
65 lines (55 loc) · 1.71 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// to run local gulp: ./node_modules/.bin/gulp <task>
// to create dist: ./node_modules/.bin/gulp package
// to publish package: cd dist; npm publish; cd ..\
var bump = require('gulp-bump'),
del = require('del'),
exec = require('child_process').exec,
gulp = require('gulp'),
merge = require('merge2'),
typescript = require('gulp-typescript'),
fs = require('fs');
gulp.task('clean', function () {
del(['dist/*']);
});
gulp.task('bump', ['clean'], function () {
gulp.src('./package.json')
.pipe(bump({
type: 'patch'
}))
.pipe(gulp.dest('./'));
});
gulp.task('bundle', ['bump'], function () {
var tsResult = gulp.src('src/*.ts')
.pipe(typescript({
module: "commonjs",
target: "es5",
noImplicitAny: true,
experimentalDecorators: true,
outDir: "dist/",
rootDir: "src/",
sourceMap: true,
declaration: true,
moduleResolution: "node",
removeComments: false,
lib: [
"es2015",
"dom"
],
types: ["jasmine"]
}));
return merge([
tsResult.dts.pipe(gulp.dest('dist/')),
tsResult.js.pipe(gulp.dest('dist/'))
]);
});
gulp.task('copy', ['bundle'], () => {
gulp.src(['src/adal-angular.d.ts', 'README.md', 'LICENSE'])
.pipe(gulp.dest('dist/'));
});
gulp.task('package', ['copy'], () => {
const pkgjson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
delete pkgjson.scripts;
delete pkgjson.devDependencies;
const filepath = './dist/package.json';
fs.writeFileSync(filepath, JSON.stringify(pkgjson, null, 2), 'utf-8');
});