grunt-filerev icon indicating copy to clipboard operation
grunt-filerev copied to clipboard

dropCwd option, fixes #15

Open sladex opened this issue 11 years ago • 6 comments

filerev: {
    options: {
        dropCwd: true
    },
    css: {
        expand: true,
        cwd: 'public',
        src: ['css/main.css'],
        dest: 'public'
}

would result:

{ '/css/main.css': '/css/main.4458448b.css' }

instead of:

{ 'public/css/main.css': 'public/css/main.4458448b.css' }

~~If you want to drop heading / as well cwd has to be specified as public/~~ upd. bad idea

sladex avatar Sep 09 '14 09:09 sladex

+1 merge

madrobot avatar Nov 14 '14 17:11 madrobot

:+1: (might be useful to add some tests, though)

nelsonpecora avatar Nov 21 '14 19:11 nelsonpecora

I have rewritten the hole thing. Forget to encount the platform's specific path issues (like slashes / \\). Anyway. Here the few examples how the current version works.

{1}. Getting rid of public:

filerev: {
    options: {
        dropCwd: true
    },
    css: {
        expand: true,
        cwd: 'public',
        src: ['css/main.css'],
        dest: 'public'
}
{ 'css/main.css': 'css/main.4458448b.css' }

{2}. Nested paths:

filerev: {
    options: {
        dropCwd: true
    },
    css: {
        expand: true,
        cwd: 'public/css',
        src: ['main.css'],
        dest: 'public/css'
}
{ 'main.css': 'main.4458448b.css' }

{3}. Nested paths (unobvious):

filerev: {
    options: {
        dropCwd: true
    },
    css: {
        expand: true,
        cwd: 'public/css',
        src: ['main.css'],
        dest: 'public/assets'
}

For the dest it'll drop the part of the path which is matching cwd:

{ 'main.css': 'assets/main.4458448b.css' }

sladex avatar Nov 29 '14 19:11 sladex

Does it work in crazy-windows-backslash-world?

nelsonpecora avatar Dec 01 '14 03:12 nelsonpecora

Yes, I've checked on both windows and linux, produced the same result.

sladex avatar Dec 01 '14 07:12 sladex

Cool, :+1:

nelsonpecora avatar Dec 01 '14 14:12 nelsonpecora