mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Merge pull request #4226 from jaswilli/issue-4225
Follow symlinks when resolving theme paths.
This commit is contained in:
commit
79c3f51950
3 changed files with 25 additions and 9 deletions
|
@ -98,11 +98,6 @@ validateSettings = function (defaultSettings, model) {
|
|||
return Promise.resolve();
|
||||
};
|
||||
|
||||
// A Promise that will resolve to an object with a property for each installed theme.
|
||||
// This is necessary because certain configuration data is only available while Ghost
|
||||
// is running and at times the validations are used when it's not (e.g. tests)
|
||||
availableThemes = requireTree(config.paths.themePath);
|
||||
|
||||
validateActiveTheme = function (themeName) {
|
||||
// If Ghost is running and its availableThemes collection exists
|
||||
// give it priority.
|
||||
|
@ -110,6 +105,13 @@ validateActiveTheme = function (themeName) {
|
|||
availableThemes = Promise.resolve(config.paths.availableThemes);
|
||||
}
|
||||
|
||||
if (!availableThemes) {
|
||||
// A Promise that will resolve to an object with a property for each installed theme.
|
||||
// This is necessary because certain configuration data is only available while Ghost
|
||||
// is running and at times the validations are used when it's not (e.g. tests)
|
||||
availableThemes = requireTree(config.paths.themePath);
|
||||
}
|
||||
|
||||
return availableThemes.then(function (themes) {
|
||||
if (!themes.hasOwnProperty(themeName)) {
|
||||
return Promise.reject(new errors.ValidationError(themeName + ' cannot be activated because it is not currently installed.', 'activeTheme'));
|
||||
|
|
|
@ -19,7 +19,7 @@ models = {
|
|||
self.Base = require('./base');
|
||||
|
||||
// Require all files in this directory
|
||||
return requireTree.readAll(__dirname).then(function (modelFiles) {
|
||||
return requireTree.readAll(__dirname, {followSymlinks: false}).then(function (modelFiles) {
|
||||
// For each found file, excluding those we don't want,
|
||||
// we will require it and cache it here.
|
||||
_.each(modelFiles, function (path, fileName) {
|
||||
|
|
|
@ -4,6 +4,7 @@ var _ = require('lodash'),
|
|||
Promise = require('bluebird'),
|
||||
readdirAsync = Promise.promisify(fs.readdir),
|
||||
lstatAsync = Promise.promisify(fs.lstat),
|
||||
readlinkAsync = Promise.promisify(fs.readlink),
|
||||
|
||||
parsePackageJson = function (path, messages) {
|
||||
// Default the messages if non were passed
|
||||
|
@ -56,7 +57,8 @@ var _ = require('lodash'),
|
|||
};
|
||||
|
||||
options = _.extend({
|
||||
index: true
|
||||
index: true,
|
||||
followSymlinks: true
|
||||
}, options);
|
||||
|
||||
if (depth > 1) {
|
||||
|
@ -72,6 +74,18 @@ var _ = require('lodash'),
|
|||
return lstatAsync(fpath).then(function (result) {
|
||||
if (result.isDirectory()) {
|
||||
return readDir(fpath, options, depth + 1, messages);
|
||||
} else if (options.followSymlinks && result.isSymbolicLink()) {
|
||||
return readlinkAsync(fpath).then(function (linkPath) {
|
||||
linkPath = path.resolve(dir, linkPath);
|
||||
|
||||
return lstatAsync(linkPath).then(function (result) {
|
||||
if (result.isFile()) {
|
||||
return linkPath;
|
||||
}
|
||||
|
||||
return readDir(linkPath, options, depth + 1, messages);
|
||||
});
|
||||
});
|
||||
} else if (depth === 1 && file === 'package.json') {
|
||||
return parsePackageJson(fpath, messages);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue