Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attrs for XML does not work. #155

Closed
jovicailievski opened this issue Jan 16, 2023 · 2 comments
Closed

Attrs for XML does not work. #155

jovicailievski opened this issue Jan 16, 2023 · 2 comments

Comments

@jovicailievski
Copy link

This does not work:

   xml:
      - file: app/src/main/res/values/styles.xml
        target: resources
        attrs:
          test: test

But for the manifest it works:

      - file: AndroidManifest.xml
        target: manifest
        attrs:
          test: test

Here in xml.js I modified the function to print the args.

    setAttrs(target, attrs) {
        console.log("target:",target, "attrs:", attrs)
        var _a, _b;
        if (!this.doc) {
            return;
        }
        logger_1.Logger.v('xml', 'setAttrs', `at ${this.path} - ${target}`);
        const nodes = (_b = (_a = this.select) === null || _a === void 0 ? void 0 : _a.call(this, target, this.doc)) !== null && _b !== void 0 ? _b : [];
        nodes.forEach((n) => {
            Object.keys(attrs).forEach(attr => {
                n.setAttribute(attr, attrs[attr]);
            });
        });
        this.vfs.set(this.path, this);
    }

Output is: target: resources attrs: undefined

Error is:
TypeError: Cannot convert undefined or null to object
at Function.keys ()
at C:\Users\exfled\Desktop\Projects\tcgbulkapp\node_modules@trapezedev\project\dist\xml.js:219:20
at Array.forEach ()
at XmlFile.setAttrs (C:\Users\exfled\Desktop\Projects\tcgbulkapp\node_modules@trapezedev\project\dist\xml.js:218:15)
at execute (C:\Users\exfled\Desktop\Projects\tcgbulkapp\node_modules@trapezedev\configure\dist\operations\android\xml.js:30:27)
at async executeOperations (C:\Users\exfled\Desktop\Projects\tcgbulkapp\node_modules@trapezedev\configure\dist\tasks\run.js:52:10)
at async runCommand (C:\Users\exfled\Desktop\Projects\tcgbulkapp\node_modules@trapezedev\configure\dist\tasks\run.js:31:9)
at async C:\Users\exfled\Desktop\Projects\tcgbulkapp\node_modules@trapezedev\configure\dist\index.js:56:13
at async Command. (C:\Users\exfled\Desktop\Projects\tcgbulkapp\node_modules@trapezedev\configure\dist\util\cli.js:31:13)

Tested for nested tags, it doesn't work too.

mlynch added a commit that referenced this issue Jan 17, 2023
@mlynch
Copy link
Contributor

mlynch commented Jan 17, 2023

My bad, fixed and added tests. Will get this out shortly in the next release

@mlynch mlynch closed this as completed Jan 17, 2023
@mlynch
Copy link
Contributor

mlynch commented Jan 17, 2023

Fixed in 7.0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants