Skip to content

Commit 9111731

Browse files
author
Ives van Hoorne
committed
Fix camelizing of npm dependencies
1 parent 9ece85f commit 9111731

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

packages/app/src/app/store/entities/actions.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// @flow
22

33
import { schema, normalize } from 'normalizr';
4-
import { camelizeKeys } from 'humps';
54

65
export const ADD_ENTITIES = 'ADD_ENTITIES';
76

87
export function normalizeResult(entity: schema.Entity, result: Object) {
98
return async (dispatch: Function) => {
10-
const normalizedResult = normalize(camelizeKeys(result), entity);
9+
const normalizedResult = normalize(result, entity);
1110

1211
dispatch({
1312
type: ADD_ENTITIES,

packages/app/src/app/store/entities/sandboxes/actions/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export default {
248248
`sandboxes/${sandboxId}/dependencies`,
249249
{
250250
method: 'POST',
251+
shouldCamelize: false,
251252
body: {
252253
dependency: {
253254
name: realName,

packages/app/src/app/store/services/api.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,20 @@ export default (async function callApi(
5252
}
5353

5454
const result = await axios(options);
55-
return shouldCamelize ? camelizeKeys(result.data) : result.data;
55+
56+
const camelizedData = shouldCamelize
57+
? camelizeKeys(result.data)
58+
: result.data;
59+
60+
// Quickfix to prevent underscored dependencies from being camelized.
61+
// Never store data as keys in the future.
62+
if (
63+
camelizedData &&
64+
camelizedData.data &&
65+
camelizedData.data.npmDependencies
66+
) {
67+
camelizedData.data.npmDependencies = result.data.data.npm_dependencies;
68+
}
69+
70+
return camelizedData;
5671
});

0 commit comments

Comments
 (0)