forked from snapcar/snapcar-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
99 lines (85 loc) · 2.42 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
var configFileCreationNeeded = function() {
return !grunt.file.exists('test/config.js')
};
grunt.initConfig({
clean: ['dist'],
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';',
},
dist: {
src: ['src/SnapCar.js'],
dest: 'dist/SnapCar.js',
},
},
uglify: {
my_target: {
files: {
'dist/SnapCar.min.js': ['dist/SnapCar.js']
}
}
},
yuidoc: {
compile: {
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
options: {
paths: 'dist/',
themedir: 'node_modules/yuidoc-lucid-theme',
helpers: ["node_modules/yuidoc-lucid-theme/helpers/helpers.js"],
outdir: 'docs'
}
}
},
mocha: {
test: {
src: ['test/**/*.html'],
options: {
run: true,
},
},
},
'gh-pages': {
options: {
base: 'docs'
},
src: "**"
},
prompt: {
target: {
options: {
questions: [
{
config: 'tests.baseDomain',
type: 'input',
message: 'Please type in the base URL of the web service on which to perform tests.',
default: 'https://apisandbox.snapcar.com/public',
when: configFileCreationNeeded,
},
{
config: 'tests.token',
type: 'input',
message: 'Please type in the token that will be used for testing.',
when: configFileCreationNeeded,
}
]
}
},
}
});
grunt.registerTask('create-config', 'Creates test config file.', function(a, b) {
if (grunt.config('tests')) {
grunt.file.write('test/config.js', 'config = ' + JSON.stringify(grunt.config('tests'), null, 2));
grunt.log.writeln('Created test/config.js file with base domain and token parameters.');
}
});
grunt.registerTask('test', ['prompt', 'create-config', 'mocha']);
grunt.registerTask('default', ['sync', 'clean', 'concat', 'uglify', 'test']);
grunt.registerTask('doc', ['default', 'yuidoc']);
grunt.registerTask('deploy-doc', ['doc', 'gh-pages']);
};