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

Use String.prototype.replace instead of String.prototype.replaceAll (PR ready) #313

Closed
nickchen120235 opened this issue Aug 4, 2021 · 2 comments · Fixed by #314
Closed

Comments

@nickchen120235
Copy link
Contributor

nickchen120235 commented Aug 4, 2021

Thanks for this awesome project!

I ran into a minor problem when using the provided gulpfile.js.

nick@Nick-PC:~/nickchen120235.github.io/assets$ gulp post -n 'hello world'
[10:46:56] Using gulpfile ~/nickchen120235.github.io/assets/gulpfile.js
[10:46:56] Starting 'post'...
[10:46:56] 'post' errored after 19 ms
[10:46:56] TypeError: title.replaceAll is not a function
    at /home/nick/nickchen120235.github.io/assets/gulpfile.js:22:71
    at post (/home/nick/nickchen120235.github.io/assets/node_modules/undertaker/lib/set-task.js:13:15)
    at bound (domain.js:416:15)
    at runBound (domain.js:427:12)
    at asyncRunner (/home/nick/nickchen120235.github.io/assets/node_modules/async-done/index.js:55:18)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

My setup is the following:

  • OS: Ubuntu 20.04 5.10.16.3-microsoft-standard-WSL2 on WSL2, Windows 10 build 10.0.19042.1110
  • node version (node -v): 14.17.4
  • npm version (npm -v): 6.14.14

The problem is that String.prototype.replaceAll() is introduced in ES2021 and my node somehow doesn't support the spec.

The fix is replacing title.replaceAll(' ', '-') with title.replace(/ /g, '-') and I think the change will make the script more robust.

@nickchen120235 nickchen120235 changed the title Use String.prototype.replace instead of String.prototype.replaceAll Use String.prototype.replace instead of String.prototype.replaceAll (PR ready) Aug 4, 2021
@sylhare
Copy link
Owner

sylhare commented Aug 5, 2021

Ah yeah I got the same issue once, thanks 👍

@sylhare
Copy link
Owner

sylhare commented Aug 5, 2021

Merged!

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 a pull request may close this issue.

2 participants