forked from OfficeDev/outlook-add-in-command-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
51 lines (46 loc) · 1.25 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
'use strict'
var gulp = require('gulp')
var webserver = require('gulp-webserver')
var fs = require('fs')
var minimist = require('minimist')
var xmllint = require('xmllint')
var chalk = require('chalk')
gulp.task('serve-static', function () {
gulp.src('.')
.pipe(webserver({
https: {
key: '../ssl/server.key',
cert: '../ssl/server.crt'
},
port: '8443',
host: 'localhost',
directoryListing: true,
fallback: 'index.html'
}))
})
gulp.task('validate-xml', function () {
var options = minimist(process.argv.slice(2))
var xsd = fs.readFileSync('./manifest.xsd')
var xmlFilePath = options.xmlfile || './manifest.xml'
var resultsAsJson = options.json || false
var xml = fs.readFileSync(xmlFilePath)
if (!resultsAsJson) {
console.log('\nValidating ' + chalk.blue(xmlFilePath.substring(xmlFilePath.lastIndexOf('/') + 1)) + ':')
}
var result = xmllint.validateXML({
xml: xml,
schema: xsd
})
if (resultsAsJson) {
console.log(JSON.stringify(result))
} else {
if (result.errors === null) {
console.log(chalk.green('Valid'))
} else {
console.log(chalk.red('Invalid'))
result.errors.forEach(function (e) {
console.log(chalk.red(e))
})
}
}
})