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) {
7
7
process . exit ( 1 ) ;
8
8
}
9
9
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
+
10
32
// we need to know any logged in Connect user token to retrieve data from DEV
11
33
const CONNECT_USER_TOKEN = process . env . CONNECT_USER_TOKEN ;
12
34
@@ -29,6 +51,7 @@ module.exports = (targetUrl, token) => {
29
51
} )
30
52
. then ( async function ( response ) {
31
53
let data = response . data ;
54
+ dummifyPrices ( data )
32
55
33
56
console . log ( 'Creating metadata objects locally...' ) ;
34
57
You can’t perform that action at this time.
0 commit comments