Skip to content

Commit

Permalink
feat(migrations): add core migration to create content/settings folder
Browse files Browse the repository at this point in the history
  • Loading branch information
aileen committed Apr 10, 2018
1 parent 8961357 commit 4d248e7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
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
}];
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 existant', 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();
});
});
});

0 comments on commit 4d248e7

Please sign in to comment.