Shanedell commented on code in PR #232:
URL: https://github.com/apache/daffodil-vscode/pull/232#discussion_r923936552
##########
build/scripts/process_build.ts:
##########
@@ -18,39 +18,81 @@
// @ts-nocheck <-- This is needed as this file is basically a JavaScript script
// but with some TypeScript niceness baked in
const fs = require('fs')
+const path = require('path')
const execSync = require('child_process').execSync
-function prebuild() {
- fs.renameSync('LICENSE', 'tmp.LICENSE')
- fs.renameSync('NOTICE', 'tmp.NOTICE')
- fs.copyFileSync('build/bin.NOTICE', 'NOTICE')
- fs.copyFileSync('build/bin.LICENSE', 'LICENSE')
+const pkg_dir = 'dist/package'
+
+function getDir(file) {
+ return file
+ .split('/')
+ .slice(0, file.split('/').length - 1)
+ .join('/')
}
-function postbuild() {
- fs.rmSync('LICENSE')
- fs.rmSync('NOTICE')
- fs.renameSync('tmp.LICENSE', 'LICENSE')
- fs.renameSync('tmp.NOTICE', 'NOTICE')
-
- // This will make sure that if the root LICENSE and NOTICE are the same as
the build LICENSE
- // and NOTICE that they are reverted back to their original contents.
- if (
- fs.readFileSync('build/bin.LICENSE').toString() ===
- fs.readFileSync('LICENSE').toString()
- ) {
- execSync('git checkout LICENSE')
+function fileCopy(srcPath, destPath) {
+ if (fs.statSync(srcPath).isFile()) {
+ fs.copyFileSync(srcPath, destPath)
}
+}
+
+function dirCopy(file) {
+ fs.readdirSync(file).forEach((dirFile) => {
+ const filePath = path.join(file, dirFile)
+ fileCopy(filePath, path.join(pkg_dir, file, dirFile))
+ })
+}
+
+function build_package() {
+ if (fs.existsSync(pkg_dir)) {
+ fs.rmdirSync(pkg_dir, { recursive: true })
+ }
+
+ fs.mkdirSync(pkg_dir)
+
+ let fileList = fs.readFileSync('.vscodeignore').toString().split('\n')
+
+ for (var i = 0; i < fileList.length; i++) {
+ var file = fileList[i].replace(/\*/gi, '').replace('!', '')
- if (
- fs.readFileSync('build/bin.NOTICE').toString() ===
- fs.readFileSync('NOTICE').toString()
- ) {
- execSync('git checkout NOTICE')
+ if (file.includes('#') || ['', '/', '\\', '\\r', '\\n'].includes(file)) {
+ continue
+ }
+
+ if (file.includes('zip')) {
+ var dir = getDir(file)
+
+ fs.readdirSync(dir).forEach((dirFile) => {
+ if (dirFile.includes('zip')) {
+ file = `${dir}/${dirFile}`
+ }
+ })
+ }
Review Comment:
Yes I like this idea and is what I used for the most recent update
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]