battleaxedotco / brutalism

Battleaxe's component library for Adobe CEP panels
https://battleaxe.dev/brutalism-docs/
MIT License
91 stars 12 forks source link

Panel‘s prop scriptPath process is incorrect when pass a array #30

Closed xh4010 closed 4 years ago

xh4010 commented 4 years ago

brutalism@2.1.4 Panel‘s prop scriptPath process is incorrect when pass a array Panel.vue:

...
realScriptPath() {
  return typeof this.scriptPath === "string"
    ? this.sanitizeString(this.scriptPath)
    : this.scriptPath.map((script) => {
        this.sanitizeString(script);      // lack return
      });
}
...
async loadScriptPath() {
  if (this.debug) console.log("Loading paths:", this.realScriptPath);
  if (typeof this.realScriptPath === "string") {
    let isFolder = await this.isFolder(this.realScriptPath);
    if (!isFolder) return await this.handlePath(this.realScriptPath);
    else if (this.exists(`${this.realScriptPath}/host.jsx`))
      return await this.handlePath(`${this.realScriptPath}/host.jsx`);
    else throw new Error(`${this.realScriptPath} is a folder, not a file`);
  } else {
    for (const scriptPath in this.realScriptPath) {    // should be use:  for-of
      let isFolder = await this.isFolder(scriptPath);
      if (!isFolder) return await this.handlePath(scriptPath);
      else if (this.exists(`${scriptPath}/host.jsx`))
        return await this.handlePath(`${scriptPath}/host.jsx`);
      else throw new Error(`${scriptPath} is a folder, not a file`);
    }
  }
}
Inventsable commented 4 years ago

Good catch 👍 There were a few typos in the code I definitely overlooked but I've fixed this via e109add78713fff74773f8eac9a631eb5c7fa413 and published 2.1.5. Since brutalism as a dependency is @latest any new bombino panels will already be updated, you can run npm i brutalism@2.1.5 to update your project.

I've also published an example panel here that shows the script-path prop working correctly as an array pointing to ./test1 and ./test2/script.jsx, both files and folders. Can you verify on your end?

xh4010 commented 4 years ago

Thanks, responsive👍, verified, no problem.

Inventsable commented 4 years ago

Great! Let us know if you find any more bugs. Closing this for now