This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Financial-Times/verify-layouts
added task to verify bower templates used in layouts exist
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
var semver = require('semver'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
module.exports = function() { | ||
return new Promise(function (resolve, reject) { | ||
var layoutBowerDeps; | ||
|
||
try { | ||
layoutBowerDeps = require(path.join(process.cwd(), 'node_modules/ft-next-express/bower.json')).dependencies; | ||
} catch (e) { | ||
console.log('No layout bower template dependencies found. Updating ft-next-express recommended'); | ||
resolve(); | ||
} | ||
|
||
Object.keys(layoutBowerDeps).forEach(function (dep) { | ||
if (!fs.exists(path.join(process.cwd(), 'bower_components', dep, '.bower.json'))) { | ||
reject('This app needs to bower install ' + dep + '#' + layoutBowerDeps[dep] + ' in order to render layouts'); | ||
} | ||
var appSemver = require(path.join(process.cwd(), 'bower_components', dep, '.bower.json')).version; | ||
|
||
if (!semver.satisfies(appSemver, layoutBowerDeps[dep])) { | ||
reject('This app needs to install a version of ' + dep + ' compatible with the semver ' + layoutBowerDeps[dep] + ' in order to render layouts'); | ||
} | ||
}); | ||
|
||
console.log('Layout bower template dependencies OK'); | ||
resolve(); | ||
}); | ||
|
||
}; |