Skip to content

Commit 4d248e7

Browse files
committed
feat(migrations): add core migration to create content/settings folder
1 parent 8961357 commit 4d248e7

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

lib/migrations.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
'use strict';
22

3-
module.exports = [];
3+
function ensureSettingsFolder() {
4+
const cwd = process.cwd();
5+
const fs = require('fs-extra');
6+
const path = require('path');
7+
8+
fs.ensureDirSync(path.resolve(cwd, 'content', 'settings'));
9+
}
10+
11+
module.exports = [{
12+
before: '1.7.0',
13+
title: 'Create content/settings directory',
14+
task: ensureSettingsFolder
15+
}];

test/unit/migrations-spec.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
const expect = require('chai').expect;
4+
const sinon = require('sinon');
5+
6+
const migrations = require('../../lib/migrations');
7+
8+
describe('Unit: Migrations', function () {
9+
describe('ensureSettingsFolder', function () {
10+
const setupEnv = require('../utils/env');
11+
const path = require('path');
12+
const fs = require('fs');
13+
14+
it('creates settings folder if not existant', function () {
15+
const env = setupEnv();
16+
const cwdStub = sinon.stub(process, 'cwd').returns(env.dir);
17+
const ensureSettingsFolder = migrations[0].task;
18+
19+
ensureSettingsFolder();
20+
expect(cwdStub.calledOnce).to.be.true;
21+
expect(fs.existsSync(path.join(env.dir, 'content/settings'))).to.be.true;
22+
23+
cwdStub.restore();
24+
env.cleanup();
25+
});
26+
});
27+
});

0 commit comments

Comments
 (0)