twolfson / grunt-curl

Download files from the internet via grunt.
The Unlicense
73 stars 28 forks source link

Multiple files to folder fails #19

Closed svdoever closed 10 years ago

svdoever commented 10 years ago

On Windows I try to do the following:

curl: {
        'ionic-nightly-css': {
            src: 'http://code.ionicframework.com/nightly/css/ionic.min.css',
            dest: 'app/vendor/ionic/css/ionic.min.css'
        },
        'ionic-nightly-js': {
            src: 'http://code.ionicframework.com/nightly/js/ionic.bundle.min.js',
            dest: 'app/vendor/ionic/js/ionic.bundle.min.js'
        },
        'ionic-nightly-fonts': {
            src: [
                'http://code.ionicframework.com/nightly/fonts/ionicons.eot',
                'http://code.ionicframework.com/nightly/fonts/ionicons.ttf',
                'http://code.ionicframework.com/nightly/fonts/ionicons.svg',
                'http://code.ionicframework.com/nightly/fonts/ionicons.woff'
            ],
            dest: 'app/vendor/ionic/fonts'
        }
    },

First two curl's work, last one (multiple src files) gives error: Fatal error: EISDIR, illegal operation on a directory 'C:\blablabla\app\vendor\ionic\fonts'

svdoever commented 10 years ago

For now I solved it with:

       curl: {
        'ionic-nightly-css': {
            src: 'http://code.ionicframework.com/nightly/css/ionic.min.css',
            dest: 'app/vendor/ionic/css/ionic.min.css'
        },
        'ionic-nightly-js': {
            src: 'http://code.ionicframework.com/nightly/js/ionic.bundle.min.js',
            dest: 'app/vendor/ionic/js/ionic.bundle.min.js'
        },
        'ionic-nightly-fonts-eot': {
            src: 'http://code.ionicframework.com/nightly/fonts/ionicons.eot',
            dest: 'app/vendor/ionic/fonts/ionicons.eot'
        },
        'ionic-nightly-fonts-ttf': {
            src: 'http://code.ionicframework.com/nightly/fonts/ionicons.ttf',
            dest: 'app/vendor/ionic/fonts/ionicons.ttf'
        },
        'ionic-nightly-fonts-svg': {
            src: 'http://code.ionicframework.com/nightly/fonts/ionicons.svg',
            dest: 'app/vendor/ionic/fonts/ionicons.svg'
        },
        'ionic-nightly-fonts-woff': {
            src: 'http://code.ionicframework.com/nightly/fonts/ionicons.woff',
            dest: 'app/vendor/ionic/fonts/ionicons.woff'
        }
    },

And a task:

    grunt.registerTask('get-ionic-nightly', function(target) {
   grunt.task.run([
       'curl:ionic-nightly-css',
       'curl:ionic-nightly-js',
       'curl:ionic-nightly-fonts-eot',
       'curl:ionic-nightly-fonts-ttf',
       'curl:ionic-nightly-fonts-svg',
       'curl:ionic-nightly-fonts-woff'
   ]);
});

Not ideal, but it works...

twolfson commented 10 years ago

As written in the documentation, the curl task only supports one file at a time. It is built that way to prevent it from becoming too magical. I did not want to lock in one behavior and not leave room for something more suiting (e.g. concatenation of said files).

To remedy that, I created curl-dir (also in the documentation) which accepts/downloads multiple files.

https://github.com/twolfson/grunt-curl#documentation

svdoever commented 10 years ago

Thanks for your quick response! You are so right, it was late, I overlooked the curl-dir command, I thought it was another example under curl, and that it did not work. I rewrote my code to:

         curl: {
        'ionic-nightly-css': {
            src: 'http://code.ionicframework.com/nightly/css/ionic.min.css',
            dest: 'app/vendor/ionic/css/ionic.min.css'
        },
        'ionic-nightly-js': {
            src: 'http://code.ionicframework.com/nightly/js/ionic.bundle.min.js',
            dest: 'app/vendor/ionic/js/ionic.bundle.min.js'
        }
    },
    'curl-dir': {
        'ionic-nightly-fonts': {
            src: [
                'http://code.ionicframework.com/nightly/fonts/ionicons.eot',
                'http://code.ionicframework.com/nightly/fonts/ionicons.ttf',
                'http://code.ionicframework.com/nightly/fonts/ionicons.svg',
                'http://code.ionicframework.com/nightly/fonts/ionicons.woff'
            ],
            dest: 'app/vendor/ionic/fonts'
        }
    },

And a task:

    grunt.registerTask('get-ionic-nightly', function(target) {
   grunt.task.run([
       'curl:ionic-nightly-css',
       'curl:ionic-nightly-js',
       'curl-dir:ionic-nightly-fonts'
   ]);
});