Skip to content

Commit 965f3e3

Browse files
committed
Merge branch 'dev' of https://github.com/coreui/coreui into dev
2 parents 623ab97 + 8f0e1b5 commit 965f3e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5223
-3277
lines changed

build/generate-sri.mjs

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ import fs from 'node:fs'
1414
import path from 'node:path'
1515
import { fileURLToPath } from 'node:url'
1616
import sh from 'shelljs'
17+
import pkg from '../package.json' with { type: 'json' }
1718

1819
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1920

2021
sh.config.fatal = true
2122

2223
const configFile = path.join(__dirname, '../hugo.yml')
24+
const isCanaryVersion = pkg.version.includes('canary')
25+
26+
console.log(isCanaryVersion)
2327

2428
// Array of objects which holds the files to generate SRI hashes for.
2529
// `file` is the path from the root folder
@@ -69,12 +73,13 @@ for (const { file, configPropertyName } of files) {
6973
throw error
7074
}
7175

76+
const propertyName = isCanaryVersion ? `canary_${configPropertyName}` : configPropertyName
7277
const algorithm = 'sha384'
7378
const hash = crypto.createHash(algorithm).update(data, 'utf8').digest('base64')
7479
const integrity = `${algorithm}-${hash}`
7580

76-
console.log(`${configPropertyName}: ${integrity}`)
81+
console.log(`${propertyName}: ${integrity}`)
7782

78-
sh.sed('-i', new RegExp(`^(\\s+${configPropertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile)
83+
sh.sed('-i', new RegExp(`^(\\s+${propertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile)
7984
})
8085
}

0 commit comments

Comments
 (0)