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:
parent
ccbd33e064
commit
037be7266b
@ -22,6 +22,12 @@ if [ -z "$npm_bin" ] || [ "$fried_twinkie_config" -eq "0" ]; then
|
||||
exit 1
|
||||
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
|
||||
|
||||
get_node_path() {
|
||||
|
@ -42,14 +42,18 @@ fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => {
|
||||
console.log('error /polygerrit-ui/temp/behaviors/ directory');
|
||||
}
|
||||
const behaviors = data;
|
||||
const externs = [];
|
||||
const additionalSources = [];
|
||||
const externMap = {};
|
||||
|
||||
for (const behavior of behaviors) {
|
||||
externs.push({
|
||||
path: `./polygerrit-ui/temp/behaviors/${behavior}`,
|
||||
src: fs.readFileSync(
|
||||
`./polygerrit-ui/temp/behaviors/${behavior}`, 'utf-8'),
|
||||
});
|
||||
if (!externMap[behavior]) {
|
||||
additionalSources.push({
|
||||
path: `./polygerrit-ui/temp/behaviors/${behavior}`,
|
||||
src: fs.readFileSync(
|
||||
`./polygerrit-ui/temp/behaviors/${behavior}`, 'utf-8'),
|
||||
});
|
||||
externMap[behavior] = true;
|
||||
}
|
||||
}
|
||||
|
||||
let mappings = JSON.parse(fs.readFileSync(
|
||||
@ -80,28 +84,30 @@ fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => {
|
||||
mappings = mappingSpecificFile;
|
||||
}
|
||||
|
||||
externs.push({
|
||||
additionalSources.push({
|
||||
path: 'custom-externs.js',
|
||||
src: '/** @externs */' +
|
||||
EXTERN_NAMES.map( name => { return `var ${name};`; }).join(' '),
|
||||
});
|
||||
|
||||
const promises = [];
|
||||
|
||||
const toCheck = [];
|
||||
for (key of Object.keys(mappings)) {
|
||||
if (mappings[key].html && mappings[key].js) {
|
||||
promises.push(twinkie.checkTemplate(
|
||||
mappings[key].html,
|
||||
mappings[key].js,
|
||||
'polygerrit.' + mappings[key].package,
|
||||
externs
|
||||
));
|
||||
toCheck.push({
|
||||
htmlSrcPath: mappings[key].html,
|
||||
jsSrcPath: mappings[key].js,
|
||||
jsModule: 'polygerrit.' + mappings[key].package,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Promise.all(promises).then(() => {}, joinedErrors => {
|
||||
if (joinedErrors) {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
twinkie.checkTemplate(toCheck, additionalSources)
|
||||
.then(() => {}, joinedErrors => {
|
||||
if (joinedErrors) {
|
||||
process.exit(1);
|
||||
}
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user