Make template testing faster
Utilizes a newer version of fried-twinkie that has significant speed
improvements.
Change-Id: I0c80cd35a6e6d79e37e7c8080982e7683f70bf7a
(cherry picked from commit 602ccf222c
)
This commit is contained in:

committed by
Paladox none

parent
ccbd33e064
commit
037be7266b
@@ -22,6 +22,12 @@ if [ -z "$npm_bin" ] || [ "$fried_twinkie_config" -eq "0" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
twinkie_version=$(npm list -g fried-twinkie@\>0.1 | grep fried-twinkie || :)
|
||||||
|
if [ -z "$twinkie_version" ]; then
|
||||||
|
echo "Outdated version of fried-twinkie found. Bypassing template check."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Have to find where node_modules are installed and set the NODE_PATH
|
# Have to find where node_modules are installed and set the NODE_PATH
|
||||||
|
|
||||||
get_node_path() {
|
get_node_path() {
|
||||||
|
@@ -42,14 +42,18 @@ fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => {
|
|||||||
console.log('error /polygerrit-ui/temp/behaviors/ directory');
|
console.log('error /polygerrit-ui/temp/behaviors/ directory');
|
||||||
}
|
}
|
||||||
const behaviors = data;
|
const behaviors = data;
|
||||||
const externs = [];
|
const additionalSources = [];
|
||||||
|
const externMap = {};
|
||||||
|
|
||||||
for (const behavior of behaviors) {
|
for (const behavior of behaviors) {
|
||||||
externs.push({
|
if (!externMap[behavior]) {
|
||||||
path: `./polygerrit-ui/temp/behaviors/${behavior}`,
|
additionalSources.push({
|
||||||
src: fs.readFileSync(
|
path: `./polygerrit-ui/temp/behaviors/${behavior}`,
|
||||||
`./polygerrit-ui/temp/behaviors/${behavior}`, 'utf-8'),
|
src: fs.readFileSync(
|
||||||
});
|
`./polygerrit-ui/temp/behaviors/${behavior}`, 'utf-8'),
|
||||||
|
});
|
||||||
|
externMap[behavior] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mappings = JSON.parse(fs.readFileSync(
|
let mappings = JSON.parse(fs.readFileSync(
|
||||||
@@ -80,28 +84,30 @@ fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => {
|
|||||||
mappings = mappingSpecificFile;
|
mappings = mappingSpecificFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
externs.push({
|
additionalSources.push({
|
||||||
path: 'custom-externs.js',
|
path: 'custom-externs.js',
|
||||||
src: '/** @externs */' +
|
src: '/** @externs */' +
|
||||||
EXTERN_NAMES.map( name => { return `var ${name};`; }).join(' '),
|
EXTERN_NAMES.map( name => { return `var ${name};`; }).join(' '),
|
||||||
});
|
});
|
||||||
|
|
||||||
const promises = [];
|
const toCheck = [];
|
||||||
|
|
||||||
for (key of Object.keys(mappings)) {
|
for (key of Object.keys(mappings)) {
|
||||||
if (mappings[key].html && mappings[key].js) {
|
if (mappings[key].html && mappings[key].js) {
|
||||||
promises.push(twinkie.checkTemplate(
|
toCheck.push({
|
||||||
mappings[key].html,
|
htmlSrcPath: mappings[key].html,
|
||||||
mappings[key].js,
|
jsSrcPath: mappings[key].js,
|
||||||
'polygerrit.' + mappings[key].package,
|
jsModule: 'polygerrit.' + mappings[key].package,
|
||||||
externs
|
});
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(promises).then(() => {}, joinedErrors => {
|
twinkie.checkTemplate(toCheck, additionalSources)
|
||||||
if (joinedErrors) {
|
.then(() => {}, joinedErrors => {
|
||||||
process.exit(1);
|
if (joinedErrors) {
|
||||||
}
|
process.exit(1);
|
||||||
});
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
console.error(e);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user