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 6744cb0
Show file tree
Hide file tree
Showing 2 changed files with 17 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,
}
16 changes: 16 additions & 0 deletions scripts/replace-build-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,25 @@ 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 newFileName = fileName.replace(/-(us|eu)/, '')
return `/**\n * ${fileName} IS DEPRECATED, USE ${newFileName} WITH DATACENTER CONFIGURATION INSTEAD\n */`
}

0 comments on commit 6744cb0

Please sign in to comment.