Shanedell commented on code in PR #232:
URL: https://github.com/apache/daffodil-vscode/pull/232#discussion_r923952909
##########
build/scripts/process_build.ts:
##########
@@ -18,39 +18,88 @@
// @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('#') ||
+ file == '' ||
+ file == '/' ||
+ file == '\\' ||
+ file == '\\r' ||
+ file === '\\n'
+ ) {
+ continue
+ }
+
+ if (file.includes('zip')) {
+ var dir = getDir(file)
+
+ fs.readdirSync(dir).forEach((dirFile) => {
+ if (dirFile.includes('zip')) {
+ file = `${dir}/${dirFile}`
+ }
+ })
+ }
+
+ let directory = fs.statSync(file).isFile() ? getDir(file) : file
+
+ fs.mkdirSync(`${pkg_dir}/${directory}`, { recursive: true })
+
+ fs.statSync(file).isFile()
+ ? fileCopy(file, `${pkg_dir}/${file}`)
+ : dirCopy(file)
}
+
+ fileCopy('.vscodeignore', `${pkg_dir}/.vscodeignore`)
+ execSync('yarn install', { cwd: pkg_dir })
+ execSync('yarn package', { cwd: pkg_dir })
Review Comment:
So to do this how you were saying however, we would need to still run a
`yarn install` before hand. But could copy in the yarn.lock, still ignore it
and keep it out of the VSIX, to make sure nothing breaks and then it would be
good to go.
--
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]