utils.js (angular.js-1.7.9) | : | utils.js (angular.js-1.8.0) | ||
---|---|---|---|---|
'use strict'; | 'use strict'; | |||
var fs = require('fs'); | var fs = require('fs'); | |||
var shell = require('shelljs'); | var shell = require('shelljs'); | |||
var grunt = require('grunt'); | var grunt = require('grunt'); | |||
var spawn = require('npm-run').spawn; | var spawn = require('npm-run').spawn; | |||
var CSP_CSS_HEADER = '/* Include this file in your html if you are using the CSP mode. */\n\n'; | var CSP_CSS_HEADER = '/* Include this file in your html if you are using the CSP mode. */\n\n'; | |||
const docsScriptFolder = 'scripts/docs.angularjs.org-firebase'; | ||||
module.exports = { | module.exports = { | |||
startKarma: function(config, singleRun, done) { | startKarma: function(config, singleRun, done) { | |||
var browsers = grunt.option('browsers'); | var browsers = grunt.option('browsers'); | |||
var reporters = grunt.option('reporters'); | var reporters = grunt.option('reporters'); | |||
var noColor = grunt.option('no-colors'); | var noColor = grunt.option('no-colors'); | |||
var port = grunt.option('port'); | var port = grunt.option('port'); | |||
var p = spawn('karma', ['start', config, | var p = spawn('karma', ['start', config, | |||
singleRun ? '--single-run=true' : '', | singleRun ? '--single-run=true' : '', | |||
reporters ? '--reporters=' + reporters : '', | reporters ? '--reporters=' + reporters : '', | |||
skipping to change at line 33 | skipping to change at line 35 | |||
]); | ]); | |||
p.stdout.pipe(process.stdout); | p.stdout.pipe(process.stdout); | |||
p.stderr.pipe(process.stderr); | p.stderr.pipe(process.stderr); | |||
p.on('exit', function(code) { | p.on('exit', function(code) { | |||
if (code !== 0) grunt.fail.warn('Karma test(s) failed. Exit code: ' + code ); | if (code !== 0) grunt.fail.warn('Karma test(s) failed. Exit code: ' + code ); | |||
done(); | done(); | |||
}); | }); | |||
}, | }, | |||
updateWebdriver: function(done) { | updateWebdriver: function(done) { | |||
if (process.env.TRAVIS) { | if (process.env.CI) { | |||
// Skip the webdriver-manager update on Travis, since the browsers will | // Skip the webdriver-manager update on CI, since the browsers will | |||
// be provided remotely. | // be provided remotely. | |||
done(); | done(); | |||
return; | return; | |||
} | } | |||
var p = spawn('webdriver-manager', ['update']); | var p = spawn('webdriver-manager', ['update']); | |||
p.stdout.pipe(process.stdout); | p.stdout.pipe(process.stdout); | |||
p.stderr.pipe(process.stderr); | p.stderr.pipe(process.stderr); | |||
p.on('exit', function(code) { | p.on('exit', function(code) { | |||
if (code !== 0) grunt.fail.warn('Webdriver failed to update'); | if (code !== 0) grunt.fail.warn('Webdriver failed to update'); | |||
done(); | done(); | |||
skipping to change at line 108 | skipping to change at line 110 | |||
.replace(/\s*\{\s*/g, '{') | .replace(/\s*\{\s*/g, '{') | |||
.replace(/\s*\}\s*/g, '}') | .replace(/\s*\}\s*/g, '}') | |||
.replace(/\s*,\s*/g, ',') | .replace(/\s*,\s*/g, ',') | |||
.replace(/\s*;\s*/g, ';'); | .replace(/\s*;\s*/g, ';'); | |||
} | } | |||
//escape for js | //escape for js | |||
css = css | css = css | |||
.replace(/\\/g, '\\\\') | .replace(/\\/g, '\\\\') | |||
.replace(/'/g, '\\\'') | .replace(/'/g, '\\\'') | |||
.replace(/\r?\n/g, '\\n'); | .replace(/\r?\n/g, '\\n'); | |||
js = '!window.angular.$$csp().noInlineStyle && window.angular.element(docu ment.head).prepend(\'<style type="text/css">' + css + '</style>\');'; | js = '!window.angular.$$csp().noInlineStyle && window.angular.element(docu ment.head).prepend(window.angular.element(\'<style>\').text(\'' + css + '\'));'; | |||
state.js.push(js); | state.js.push(js); | |||
return state; | return state; | |||
} | } | |||
}, | }, | |||
process: function(src, NG_VERSION, strict) { | process: function(src, NG_VERSION, strict) { | |||
var processed = src | var processed = src | |||
.replace(/(['"])NG_VERSION_FULL\1/g, NG_VERSION.full) | .replace(/(['"])NG_VERSION_FULL\1/g, NG_VERSION.full) | |||
.replace(/(['"])NG_VERSION_MAJOR\1/, NG_VERSION.major) | .replace(/(['"])NG_VERSION_MAJOR\1/, NG_VERSION.major) | |||
skipping to change at line 291 | skipping to change at line 293 | |||
match; | match; | |||
if (!IGNORED.test(req.url) && (match = req.url.match(REWRITE))) { | if (!IGNORED.test(req.url) && (match = req.url.match(REWRITE))) { | |||
console.log('rewriting', req.url); | console.log('rewriting', req.url); | |||
req.url = req.url.replace(match[0], '/index.html'); | req.url = req.url.replace(match[0], '/index.html'); | |||
} | } | |||
next(); | next(); | |||
}; | }; | |||
}, | }, | |||
// Our Firebase projects are in subfolders, but Travis expects them in the roo | docsScriptFolder, | |||
t, | ||||
// so we need to modify the upload folder path and copy the file into the root | ||||
firebaseDocsJsonForTravis: function() { | ||||
var docsScriptFolder = 'scripts/docs.angularjs.org-firebase'; | ||||
// Our Firebase projects are in subfolders, but the firebase tool expects them | ||||
in the root, | ||||
// so we need to modify the upload folder path and copy the file into the root | ||||
firebaseDocsJsonForCI: function() { | ||||
var fileName = docsScriptFolder + '/firebase.json'; | var fileName = docsScriptFolder + '/firebase.json'; | |||
var json = grunt.file.readJSON(fileName); | var json = grunt.file.readJSON(fileName); | |||
(json.hosting || (json.hosting = {})).public = 'deploy/docs'; | (json.hosting || (json.hosting = {})).public = 'deploy/docs'; | |||
(json.functions || (json.functions = {})).source = docsScriptFolder + '/func tions'; | (json.functions || (json.functions = {})).source = docsScriptFolder + '/func tions'; | |||
grunt.file.write('firebase.json', JSON.stringify(json)); | grunt.file.write('firebase.json', JSON.stringify(json)); | |||
} | } | |||
}; | }; | |||
End of changes. 5 change blocks. | ||||
8 lines changed or deleted | 10 lines changed or added |