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

through2-map #6

Open
yocontra opened this issue Apr 20, 2014 · 6 comments
Open

through2-map #6

yocontra opened this issue Apr 20, 2014 · 6 comments

Comments

@yocontra
Copy link
Member

pseudocode

var map = require('through2-map');

var scriptTag = "<script>document.write('<script src=\"http://' + (location.host || 'localhost').split(':')[0] + ':"+lrPort+"/livereload.js?snipver=1\"></' + 'script>')</script>";
var endTag = /<\/body>/i;

var found = false;
var injectLR = map({wantStrings: true}, function (str) {
  if (!found && str.indexOf(endTag)) {
    found = true;
    return str.replace(endTag, scriptTag+'\r\n</body>');
  }
  return str;
});
@w33ble
Copy link
Contributor

w33ble commented Apr 22, 2014

The problem with the found check is that it never changes back to false, so it only does the replace once. The live-reload and watch process don't restart the server, it just reloads the page, without the LR the second time.

Thanks though, PR coming shortly, sans the found flag.

@yocontra
Copy link
Member Author

Actually just use the replace-stream module for this, no need to reinvent the wheel. I forgot it existed.

@w33ble
Copy link
Contributor

w33ble commented Apr 22, 2014

@yocontra
Copy link
Member Author

yup

@w33ble
Copy link
Contributor

w33ble commented Apr 22, 2014

I don't know how to link a PR to an existing issue. #7 opened

@w33ble
Copy link
Contributor

w33ble commented Apr 22, 2014

Solid idea, lute is basically all 3rd party libs now. @funkytek we should wrap all this up in a gulp plugin (or just use gulp for all this) and start adding the static generation stuff now.

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