Skip to content

Commit

Permalink
fix: The Manager didn't get the partials anymore since a very long time
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Jan 11, 2017
1 parent ba4bed4 commit faac821
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
10 changes: 8 additions & 2 deletions src/cli/cms/templates/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ import {
} from '../../'
import * as sourceAttr from '../../cms/editor/handlebars/sourceAttr'

export function getTemplatesAndPartials(templatesPath) {
export function getTemplatesAndPartials(templatesPath, partialsPath) {
let allFiles = []
var p = new Promise((resolve) => {
const extension = '.' + config.files.templates.extension
return coreUtils.file.getFilesAsync(templatesPath, true, extension)
.then(function(files){
allFiles = allFiles.concat(files)
return coreUtils.file.getFilesAsync(partialsPath, true, extension)
.then(function(files){
return resolve(files)
allFiles = allFiles.concat(files)
return resolve(allFiles)
})
})
})

return p
Expand Down
2 changes: 1 addition & 1 deletion src/cli/core/manager/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Manager {
this._whereKeys = []
var p = new Promise((resolve) => {

cmsTemplates.template.getTemplatesAndPartials(this._pathTemplate)
cmsTemplates.template.getTemplatesAndPartials(this._pathTemplate, this._pathPartials)
.then((templatesList) => {

return cmsTemplates.template.getTemplatesTexts(templatesList)
Expand Down
15 changes: 4 additions & 11 deletions test/cms/templates/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe('cmsTemplates', function() {
templatePaths: path.join(process.cwd(), 'test', 'fixtures', 'templates', 'templates/article.html'),
structurePaths: path.join(process.cwd(), 'test', 'fixtures', 'templates', 'templates/structure/0-1'),
import: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'import.html'), 'utf-8'),
pathTemplates: path.join(process.cwd(), 'test', 'fixtures', 'templates'),
pathPartials: path.join(process.cwd(), 'test', 'fixtures', 'partials'),
count: 0
}
done()
Expand All @@ -44,20 +46,11 @@ describe('cmsTemplates', function() {
*
*/
it('cmsTemplates.template.getTemplatesAndPartials()', function(done) {
// stub
var sinonInstance = sinon.sandbox.create();
var getFilesAsync = sinonInstance.stub(coreUtils.file, 'getFilesAsync');
getFilesAsync.returns(Promise.resolve([this.fixture.article]))

// test
cmsTemplates.template.getTemplatesAndPartials(this._pathTemplate)
cmsTemplates.template.getTemplatesAndPartials(this.fixture.pathTemplates, this.fixture.pathPartials)
.then((templatesList) => {
chai.expect(templatesList.length).to.be.equal(1);
chai.expect(templatesList.length).to.be.equal(28);
done()

// unstub
sinon.assert.calledOnce(coreUtils.file.getFilesAsync)
coreUtils.file.getFilesAsync.restore()
})
});

Expand Down

0 comments on commit faac821

Please sign in to comment.