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

Error with Either String or RegEx #54

Closed
yuschick opened this issue Jun 26, 2018 · 2 comments
Closed

Error with Either String or RegEx #54

yuschick opened this issue Jun 26, 2018 · 2 comments

Comments

@yuschick
Copy link

Hello,

I am trying to use this library via its CLI.

"scripts": {
    ...
    "replace": "replace-in-file --configFile=replace-config.js"
}

My config file looks like this:

const replace = require('replace-in-file');

const options = {
  files: '/sitemap.xml',
  from: /\?>$/,
  to: `?>
  <?xml-stylesheet type="text/xsl" href="/sitemap-template.xsl"?>
  `,
};

replace(options);

However, when running that I receive an error.

throw new Error('Must specify string or regex to replace');

Whether I provide a regex or string in the from property, I continue to receive the error. Am I doing something wrong in the config file?

@yuschick
Copy link
Author

Found my answer here: #37

@adamreisnz
Copy link
Owner

Yep, I reckon the issue was that the configuration file wasn't exporting a JSON/JS object? 👍

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