index.js
function _getUi5AppHash(sResolvedModulePath, sPreloadPath, oOptions) {
  // read relevant resources for hash generation
  const oPreloadFileContent = fs.readFileSync(sPreloadPath, 'utf8')

  // some resources will be requested additionally to 'Component-preload.js'
  // fortunately they 'should' be listed in manifest.json, therefore, we will look them up there
  const sManifestPath = path.resolve(sResolvedModulePath, 'manifest.json')
  const oManifestFileContent = fs.existsSync(sManifestPath)
    ? fs.readFileSync(sManifestPath, 'utf8')
    : null
  const oManifestJSON = oManifestFileContent
    ? JSON.parse(oManifestFileContent)
    : { 'sap.ui5': {} }
  const aResourceKeys = oManifestJSON['sap.ui5'].resources
    ? Object.keys(oManifestJSON['sap.ui5'].resources)
    : []
  const aDependedResourceContents = aResourceKeys.reduce(
    (aContentsList, sResourceKey) => {
      return aContentsList.concat(
        oManifestJSON['sap.ui5'].resources[sResourceKey].map(oResource =>
          fs.readFileSync(
            path.resolve(sResolvedModulePath, oResource.uri),
            'utf8'
          )
        )
      )
    },
    []
  )

  // generate hash based on resource contents of the app
  const aBufferList = aDependedResourceContents
    .concat(oPreloadFileContent ? oPreloadFileContent : [])
    .map(oContent => new Buffer(oContent))
  const sNewHash = _createHash(aBufferList, oOptions)

  return sNewHash
}
function _getUi5AppHash(sResolvedModulePath, sPreloadPath, oOptions) {
  // read relevant resources for hash generation
  const oPreloadFileContent = fs.readFileSync(sPreloadPath, 'utf8')

  // some resources will be requested additionally to 'Component-preload.js'
  // fortunately they 'should' be listed in manifest.json, therefore, we will look them up there
  const sManifestPath = path.resolve(sResolvedModulePath, 'manifest.json')
  const oManifestFileContent = fs.existsSync(sManifestPath)
    ? fs.readFileSync(sManifestPath, 'utf8')
    : null
  const oManifestJSON = oManifestFileContent
    ? JSON.parse(oManifestFileContent)
    : { 'sap.ui5': {} }
  const aResourceKeys = oManifestJSON['sap.ui5'].resources
    ? Object.keys(oManifestJSON['sap.ui5'].resources)
    : []
  const aDependedResourceContents = aResourceKeys.reduce(
    (aContentsList, sResourceKey) => {
      return aContentsList.concat(
        oManifestJSON['sap.ui5'].resources[sResourceKey].map(oResource =>
          fs.readFileSync(
            path.resolve(sResolvedModulePath, oResource.uri),
            'utf8'
          )
        )
      )
    },
    []
  )

  // generate hash based on resource contents of the app
  const aBufferList = aDependedResourceContents
    .concat(oPreloadFileContent ? oPreloadFileContent : [])
    .map(oContent => new Buffer(oContent))
  const sNewHash = _createHash(aBufferList, oOptions)

  return sNewHash
}
function _getUi5AppHash ( sResolvedModulePath , sPreloadPath , oOptions ) { // read relevant resources for hash generation const oPreloadFileContent = fs . readFileSync ( sPreloadPath , 'utf8' ) // some resources will be requested additionally to 'Component-preload.js' // fortunately they 'should' be listed in manifest.json, therefore, we will look them up there const sManifestPath = path . resolve ( sResolvedModulePath , 'manifest.json' ) const oManifestFileContent = fs . existsSync ( sManifestPath ) ? fs . readFileSync ( sManifestPath , 'utf8' ) : null const oManifestJSON = oManifestFileContent ? JSON . parse ( oManifestFileContent ) : { 'sap.ui5' : { } } const aResourceKeys = oManifestJSON [ 'sap.ui5' ] . resources ? Object . keys ( oManifestJSON [ 'sap.ui5' ] . resources ) : [ ] const aDependedResourceContents = aResourceKeys . reduce ( ( aContentsList , sResourceKey ) => { return aContentsList . concat ( oManifestJSON [ 'sap.ui5' ] . resources [ sResourceKey ] . map ( oResource => fs . readFileSync ( path . resolve ( sResolvedModulePath , oResource . uri ) , 'utf8' ) ) ) } , [ ] ) // generate hash based on resource contents of the app const aBufferList = aDependedResourceContents . concat ( oPreloadFileContent ? oPreloadFileContent : [ ] ) . map ( oContent => new Buffer ( oContent ) ) const sNewHash = _createHash ( aBufferList , oOptions ) return sNewHash }
Generate hash for UI5 app component.
@param {string} [sResolvedModulePath] Module path.
@param {string} [sPreloadPath] Path to Component-preload.js.
@param {Object} [oOptions] Cach buster options.
@param {Object} [oOptions.hash] Hash generation options.
@param {string} [oOptions.HASH_TYPE] Hash type.
@param {string} [oOptions.DIGEST_TYPE] Digest type.
@param {number} [oOptions.MAX_LENGTH] Maximum hash length.
@returns {string|null} Generated hash.
Generate hash for UI5 app component .