Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} catch (e) {
throw new Error( `\n\n\x1b[41mFAIL\x1b[0m: A JSON "\x1b[36m${path.join( level, block, 'data.json' )}\x1b[0m" have SyntaxError:\n${e.message}\n\n` )
}
}
// Read deps
if ( isFile( use ) ) {
delete require.cache[ require.resolve( use ) ]
const data = require( use )
if ( data && Array.isArray( data.modules ) ) {
data.modules.forEach( obj => {
if ( !obj || obj.constructor !== Object ) return
if ( !obj.from || typeof obj.from !== 'string' )
return ( obj.from = path.join( blocks, level, block, 'assets' ) )
if ( isExternal( obj.from ) ) return
return ( obj.from = path.join( root, obj.from ) )
})
}
if ( !deps[block] ) {
throw new Error( `\n\n\x1b[41mFAIL\x1b[0m: A JSON "\x1b[36m${path.join( level, block, 'data.json' )}\x1b[0m" have SyntaxError:\n${e.message}\n\n` )
}
}
// Read deps
if ( isFile( use ) ) {
delete require.cache[ require.resolve( use ) ]
const data = require( use )
if ( data && Array.isArray( data.modules ) ) {
data.modules.forEach( obj => {
if ( !obj || obj.constructor !== Object ) return
if ( !obj.from || typeof obj.from !== 'string' )
return ( obj.from = path.join( blocks, level, block, 'assets' ) )
if ( isExternal( obj.from ) ) return
return ( obj.from = path.join( root, obj.from ) )
})
}
if ( !deps[block] ) {
if ( data ) deps[block] = {
if ( !obj.from || typeof obj.from !== 'string' )
return ( obj.from = path.join( blocks, level, block, 'assets' ) )
if ( isExternal( obj.from ) ) return
return ( obj.from = path.join( root, obj.from ) )
})
}
if ( !deps[block] ) {
if ( data ) deps[block] = {
nodes: Array.isArray( data.nodes ) ? data.nodes : [],
modules: Array.isArray( data.modules ) ? data.modules : []
}
} else {
if ( data ) deps[block] = {
nodes: Array.isArray( data.nodes ) ? deps[block].nodes.concat( data.nodes ) : deps[block].nodes,
modules: Array.isArray( data.modules ) ? deps[block].modules.concat( data.modules ) : deps[block].modules
}
}
}
})
})
}
if ( !deps[block] ) {
if ( data ) deps[block] = {
nodes: Array.isArray( data.nodes ) ? data.nodes : [],
modules: Array.isArray( data.modules ) ? data.modules : []
}
} else {
if ( data ) deps[block] = {
nodes: Array.isArray( data.nodes ) ? deps[block].nodes.concat( data.nodes ) : deps[block].nodes,
modules: Array.isArray( data.modules ) ? deps[block].modules.concat( data.modules ) : deps[block].modules
}
}
}
})