-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(migrations): add core migration to create content/settings folder
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}); |