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

Support saving to multiple routes #11

Closed
wants to merge 1 commit into from

Conversation

gregersrygg
Copy link

For java projects it's normal to have a source and a target directory. The local web server will use the file in the target directory, but also the source file has to be updated so the changes will not be deleted on the next project build.

The diff looks pretty terrifying, but I only changed the for-loop and moved the part that saves a file into an inner function.

@NV
Copy link
Owner

NV commented Mar 16, 2012

Consider the following example:

exports.routes = [
    {
        from: /[?&]autosave=off/,
        to: '/dev/null'
    },
    {
        from: /^file:\/\/[^/]*\//,
        to: '/'
    }
]

file:///Users/nv/test.html&autosave=off will stop on the first rule. Your patch breaks it.

Here is what you really want:

exports.routes = [
    {
        from: /http:\/\/dummy.local\//,
        to: ['/source', '/target']
    }
]

Would you mind to implement?

@NV
Copy link
Owner

NV commented Mar 17, 2012

I decided to not include this functionality into the core. To copy files you can pipe autosave’s output to your script:

➤ autosave | node after.js

after.js:

process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function(chunk) {
    var match = chunk.match(/Saved a \w+ to (.+)/);
    if (match) {
        var path = match[1];
        // Copy file
        // http://stackoverflow.com/questions/4980243/how-to-copy-a-file
    }
});

@NV NV closed this Mar 17, 2012
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.

2 participants