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

builtin walkSync for this.output, this.input or fake fs #49

Open
lifeart opened this issue Dec 25, 2019 · 1 comment
Open

builtin walkSync for this.output, this.input or fake fs #49

lifeart opened this issue Dec 25, 2019 · 1 comment

Comments

@lifeart
Copy link

lifeart commented Dec 25, 2019

Reading API updates regarding this.input, this.output. I'was checked original broccoli plugin documentation on website and seen such example:

https://github.com/broccolijs/broccolijs.github.io/edit/code/src/content/plugins.md

build() {
        const walkOptions = {
            includeBasePath: true,
            directories: false,
            globs: this.fileMatchers,
        };

        const content = this.inputPaths
            .reduce((output, inputPath) => output + this.joinSeparator +
                walkSync(inputPath, walkOptions)
                    .map(file => fs.readFileSync(file, { encoding: 'UTF-8' }))
                    .join(this.joinSeparator),
            '');

        fs.writeFileSync(`${this.outputPath}/${this.outputFile}`, content);
    }

How we will convert it into new api? without fs usage inside walkSync?

// @SparshithNR @stefanpenner

@lifeart lifeart changed the title builtin walkSync for this.output, this.input builtin walkSync for this.output, this.input or fake fs Dec 25, 2019
@SparshithNR
Copy link

@lifeart As of now, we do not have walksync as you mentioned. But we do have entries in this.input. So we can change the build code slightly to achieve the same goal as before.

 build() {
        const walkOptions = {
            includeBasePath: true,
            directories: false,
            globs: this.fileMatchers,
        };

        const content = this.input.entries('./', walkOptions)
                    .map(file => this.input.readFileSync(file.relativePath, { encoding: 'UTF-8' }))
                    .join(this.joinSeparator);

        fs.writeFileSync(`${this.outputPath}/${this.outputFile}`, content);
    }

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