Skip to content

Commit

Permalink
add deprecation comment on suffixed files
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Aug 7, 2020
1 parent c4c2903 commit e85b1f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/build-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ module.exports = {
TARGET_ENV: process.env.TARGET_ENV || 'staging',
BUILD_MODE: process.env.BUILD_MODE,
SDK_VERSION: sdkVersion,
WITH_SUFFIX: process.env.WITH_SUFFIX || false,
}
18 changes: 18 additions & 0 deletions scripts/replace-build-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,27 @@ try {
from: Object.keys(buildEnv).map((entry) => `<<< ${entry} >>>`),
to: Object.values(buildEnv),
})
if (buildEnv.WITH_SUFFIX) {
replace.sync({
files: `${buildDirectory}/**/*.js`,
from: /.*/,
to: (...args) =>
`${makeDeprecatedSuffixComment(args[args.length - 1])}\n${args[0]}\n${makeDeprecatedSuffixComment(
args[args.length - 1]
)}`,
})
}
console.log('Changed files:', results.filter((entry) => entry.hasChanged).map((entry) => entry.file))
process.exit(0)
} catch (error) {
console.error('Error occurred:', error)
process.exit(1)
}

function makeDeprecatedSuffixComment(filePath) {
const fileName = filePath.split('/').pop()
const suffixRegExp = /-(us|eu)/
const env = fileName.match(suffixRegExp)[1]
const newFileName = fileName.replace(suffixRegExp, '')
return `/**\n * ${fileName} IS DEPRECATED, USE ${newFileName} WITH { datacenter: '${env}' } INIT CONFIGURATION INSTEAD\n */`
}

0 comments on commit e85b1f1

Please sign in to comment.