File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,28 @@ if (!process.env.CONNECT_USER_TOKEN) {
77 process . exit ( 1 ) ;
88}
99
10+ /**
11+ * Iteratively goes through the object and replaces prices with random values.
12+ *
13+ * This method MUTATES object.
14+ *
15+ * @param {Object } o object
16+ */
17+ function dummifyPrices ( o ) {
18+ Object . keys ( o ) . forEach ( function ( k ) {
19+ if ( o [ k ] !== null && typeof o [ k ] === 'object' ) {
20+ dummifyPrices ( o [ k ] ) ;
21+ return ;
22+ }
23+ if ( k === 'price' && typeof o [ k ] === 'number' ) {
24+ o [ k ] = 100 + Math . round ( Math . random ( ) * 10000 ) ;
25+ }
26+ if ( k === 'price' && typeof o [ k ] === 'string' ) {
27+ o [ k ] = ( 100 + Math . round ( Math . random ( ) * 10000 ) ) . toFixed ( 0 ) ;
28+ }
29+ } ) ;
30+ }
31+
1032// we need to know any logged in Connect user token to retrieve data from DEV
1133const CONNECT_USER_TOKEN = process . env . CONNECT_USER_TOKEN ;
1234
@@ -29,6 +51,7 @@ module.exports = (targetUrl, token) => {
2951 } )
3052 . then ( async function ( response ) {
3153 let data = response . data ;
54+ dummifyPrices ( data )
3255
3356 console . log ( 'Creating metadata objects locally...' ) ;
3457
You can’t perform that action at this time.
0 commit comments