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

tweak pre build placeholder #311

Merged
merged 2 commits into from
Sep 18, 2024
Merged

tweak pre build placeholder #311

merged 2 commits into from
Sep 18, 2024

Conversation

lijunchen
Copy link
Contributor

No description provided.

@lijunchen lijunchen merged commit 77e3f80 into main Sep 18, 2024
10 checks passed
@lijunchen lijunchen deleted the tweak-pre-build-placeholder branch September 18, 2024 03:27
Copy link

Problems Detected in moon.pkg.json

  1. Incorrect Placeholder Syntax:

    • The placeholder syntax for input and output in the JSON commands is incorrect. The correct syntax should be ${input} and ${output} instead of $input and $output. This might lead to the build commands not being correctly substituted.
    "command": ":embed --text -i ${input} -o ${output}"
  2. Missing Quotes for Single Input/Output:

    • When there is only one input or output, it should be enclosed in quotes to ensure proper substitution. This is particularly important for the a.txt and c.txt entries.
    "input": "a.txt"

Problems Detected in generate.rs

  1. Placeholder Replacement Issue:

    • The code is replacing $input and $output with the inputs and outputs respectively. This is incorrect as the JSON commands use ${input} and ${output}. This inconsistency will cause the build commands to not be correctly substituted.
    .replace("${input}", &inputs.join(" "))
    .replace("${output}", &outputs.join(" "));
  2. Potential Misinterpretation of Commands:

    • The code assumes that the command string is correctly formatted for substitution. However, if there are any other parts of the command string that resemble $input or $output, they will also be replaced, which might not be the intended behavior.

Suggested Fixes

  1. Fix Placeholder Syntax in moon.pkg.json:

    • Correct the placeholder syntax to ${input} and ${output}.
    {
        "input": "a.txt",
        "output": "a.mbt",
        "command": ":embed --text -i ${input} -o ${output}"
    },
    {
        "input": ["b.txt"],
        "output": "b.mbt",
        "command": ":embed --binary -i ${input} -o ${output} --name _b"
    },
    {
        "input": "c.txt",
        "output": "c.mbt",
        "command": ":embed --text -i ${input} -o ${output} --name _c"
    }
  2. Fix Placeholder Replacement in generate.rs:

    • Ensure that the placeholder replacement matches the JSON syntax.
    let command = command
        .replace("${input}", &inputs.join(" "))
        .replace("${output}", &outputs.join(" "));

By making these changes, the build commands will be correctly substituted, and potential issues with placeholder misinterpretation will be avoided.

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

Successfully merging this pull request may close these issues.

1 participant