You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2022/07/18 22:29:41 UTC

[GitHub] [daffodil-vscode] Shanedell commented on a diff in pull request #232: Update build script.

Shanedell commented on code in PR #232:
URL: https://github.com/apache/daffodil-vscode/pull/232#discussion_r923911000


##########
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}`
+        }
+      })
+    }
+
+    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`)

Review Comment:
   Yeah I forgot to add those my bad, I will make sure to fix that one the next commit



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org