Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure content/settings folder #681

Merged
merged 2 commits into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/migrations.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
'use strict';

module.exports = [];
function ensureSettingsFolder() {
const cwd = process.cwd();
const fs = require('fs-extra');
const path = require('path');

fs.ensureDirSync(path.resolve(cwd, 'content', 'settings'));
}

module.exports = [{
before: '1.7.0',
title: 'Create content/settings directory',
task: ensureSettingsFolder
}];
1 change: 1 addition & 0 deletions lib/tasks/ensure-structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ module.exports = function ensureStructure() {
fs.ensureDirSync(path.resolve(cwd, 'content', 'data'));
fs.ensureDirSync(path.resolve(cwd, 'content', 'images'));
fs.ensureDirSync(path.resolve(cwd, 'content', 'logs'));
fs.ensureDirSync(path.resolve(cwd, 'content', 'settings'));
};
27 changes: 27 additions & 0 deletions test/unit/migrations-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

const expect = require('chai').expect;
const sinon = require('sinon');

const migrations = require('../../lib/migrations');

describe('Unit: Migrations', function () {
describe('ensureSettingsFolder', function () {
const setupEnv = require('../utils/env');
const path = require('path');
const fs = require('fs');

it('creates settings folder if not existent', function () {
const env = setupEnv();
const cwdStub = sinon.stub(process, 'cwd').returns(env.dir);
const ensureSettingsFolder = migrations[0].task;

ensureSettingsFolder();
expect(cwdStub.calledOnce).to.be.true;
expect(fs.existsSync(path.join(env.dir, 'content/settings'))).to.be.true;

cwdStub.restore();
env.cleanup();
});
});
});
3 changes: 2 additions & 1 deletion test/unit/tasks/ensure-structure-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('Unit: Tasks > ensure-structure', function () {
'content/themes',
'content/data',
'content/images',
'content/logs'
'content/logs',
'content/settings'
];

expectedFiles.forEach((file) => {
Expand Down