-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGruntfile.js
62 lines (51 loc) · 1.78 KB
/
Gruntfile.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
var path = require('path');
var fs = require('fs');
var targetFolder = 'deploy';
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
clean: path.join(targetFolder, '/**/*'),
options: {
'no-write': false
}
},
copy: {
main: {
files: [
{ expand: true, src: ['README.md', 'LICENSE'], dest: targetFolder },
{ expand: true, flatten: true, src: ['build/*'], dest: targetFolder },
{ expand: true, cwd:'scripts', src: ['follow-redirects/**'], dest: path.join(targetFolder, 'lib') },
],
},
},
typescript: {
base: {
src: 'scripts/*.ts',
dest: path.join(targetFolder, 'lib'),
options: {
module: 'commonjs',
target: 'es5',
rootDir: 'scripts',
declaration: false,
references: [
'scripts/**/*.d.ts'
]
}
}
},
removeDevDeps: {
src: ['.', targetFolder],
},
});
grunt.loadNpmTasks('grunt-typescript');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerMultiTask('removeDevDeps', '', function () {
var ps = 'package.json';
var src = JSON.parse(String(fs.readFileSync(path.join(this.data[0], ps))));
delete src.devDependencies;
fs.writeFileSync(path.join(this.data[1], ps), JSON.stringify(src));
});
grunt.registerTask('default', ['clean', 'typescript', 'copy', 'removeDevDeps']);
};