File tree Expand file tree Collapse file tree 3 files changed +14
-13
lines changed
app/pages/Sandbox/Editor/Workspace/Dependencies/VersionEntry Expand file tree Collapse file tree 3 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import ArrowDropUp from 'react-icons/lib/md/keyboard-arrow-up';
66import algoliasearch from 'algoliasearch/lite' ;
77import compareVersions from 'compare-versions' ;
88import Tooltip from '@codesandbox/common/lib/components/Tooltip' ;
9- import { CSB_PKG_PROTOCOL } from '@codesandbox/common/lib/utils/ci' ;
9+ import { formatVersion } from '@codesandbox/common/lib/utils/ci' ;
1010
1111import { EntryContainer , IconArea , Icon } from '../../elements' ;
1212import { Link } from '../elements' ;
@@ -27,17 +27,6 @@ interface State {
2727 versions : string [ ] ;
2828}
2929
30- function formatVersion ( version : string ) {
31- if ( CSB_PKG_PROTOCOL . test ( version ) ) {
32- const commitSha = version . match ( / c o m m i t \/ ( [ \w \d ] * ) \/ / ) ;
33- if ( commitSha && commitSha [ 1 ] ) {
34- return `csb:${ commitSha [ 1 ] } ` ;
35- }
36- }
37-
38- return version ;
39- }
40-
4130export class VersionEntry extends React . PureComponent < Props , State > {
4231 state : State = {
4332 hovering : false ,
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { formatVersion } from '@codesandbox/common/lib/utils/ci' ;
23import { Container , Row } from './elements' ;
34
45function Dependencies ( { sandbox } ) {
@@ -23,7 +24,7 @@ function Dependencies({ sandbox }) {
2324 { Object . keys ( npmDependencies ) . map ( dep => (
2425 < Row key = { dep } >
2526 < span > { dep } </ span >
26- < span > { npmDependencies [ dep ] } </ span >
27+ < span > { formatVersion ( npmDependencies [ dep ] ) } </ span >
2728 </ Row >
2829 ) ) }
2930 </ Container >
Original file line number Diff line number Diff line change 11export const CSB_PKG_PROTOCOL = / h t t p s : \/ \/ p k g ( - s t a g i n g ) ? \. c s b .d e v / ;
2+
3+ export const formatVersion = ( version : string ) => {
4+ if ( CSB_PKG_PROTOCOL . test ( version ) ) {
5+ const commitSha = version . match ( / c o m m i t \/ ( [ \w \d ] * ) \/ / ) ;
6+ if ( commitSha && commitSha [ 1 ] ) {
7+ return `csb:${ commitSha [ 1 ] } ` ;
8+ }
9+ }
10+
11+ return version ;
12+ } ;
You can’t perform that action at this time.
0 commit comments