forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (28 loc) · 794 Bytes
/
index.js
File metadata and controls
34 lines (28 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react';
import { formatVersion } from '@codesandbox/common/lib/utils/ci';
import { Container, Row } from './elements';
function Dependencies({ sandbox }) {
let { npmDependencies } = sandbox;
const packageJSON = sandbox.modules.find(
m => m.title === 'package.json' && m.directoryShortid == null
);
if (packageJSON) {
try {
npmDependencies = JSON.parse(packageJSON.code).dependencies;
} catch (e) {
console.error(e);
}
}
npmDependencies = npmDependencies || {};
return (
<Container>
{Object.keys(npmDependencies).map(dep => (
<Row key={dep}>
<span>{dep}</span>
<span>{formatVersion(npmDependencies[dep])}</span>
</Row>
))}
</Container>
);
}
export default Dependencies;