Skip to content

Commit

Permalink
feature(cloudcmd) deprecate localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed May 15, 2018
1 parent d6c3a24 commit e77e2db
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
13 changes: 9 additions & 4 deletions server/cloudcmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ const root = () => config('root');
const notEmpty = (a) => a;
const clean = (a) => a.filter(notEmpty);

const noop = () => {};
const deprecateOnePanelMode = (value) => {
const noop = () => {};

util.deprecate(noop, 'onePanelMode is deprecated, use oneFilePanel instead', 'DP0001')();

config('oneFilePanel', value);
};

const deprecateLocalStorage = (value) => {
util.deprecate(noop, 'localStorage is deprecated', 'DP0002')();
config('localStorage', value);
};

module.exports = (params) => {
const p = params || {};
const options = p.config || {};
Expand All @@ -66,7 +69,9 @@ module.exports = (params) => {
keys.forEach((name) => {
const value = options[name];

if (name === 'onePanelMode')
if (name === 'localStorage')
deprecateLocalStorage(value);
else if (name === 'onePanelMode')
deprecateOnePanelMode();
else if (name === 'oneFilePanel')
config('onePanelMode', value);
Expand Down
25 changes: 25 additions & 0 deletions test/server/cloudcmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,31 @@ test('cloudcmd: getIndexPath: development', (t) => {
t.end();
});

test('cloudcmd: deprecated: localStorage', (t) => {
const config = {
localStorage: false
};

const {
deprecate: originalDeprecate
} = util;

const deprecate = sinon
.stub()
.returns(noop);

util.deprecate = deprecate;

cloudcmd({
config
});

util.deprecate = originalDeprecate;

t.ok(deprecate.called, 'should call deprecate');
t.end();
});

test('cloudcmd: deprecated: one panel mode', (t) => {
const config = {
onePanelMode: true
Expand Down

0 comments on commit e77e2db

Please sign in to comment.