download-file-sync
Does exactly what you expects
Last updated 11 years ago by vjeux .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install download-file-sync 
SYNC missed versions from official npm registry.

download-file-sync

Ever wanted to write a node script that just downloads a file synchronously? I'm sure you sometimes wish you worked on PHP and just used file_get_contents('url'). Yeah it's going to be slow, yeah it won't scale, but that doesn't matter for your little script.

How to use?

npm install download-file-sync --save
var downloadFileSync = require('download-file-sync');
var content = downloadFileSync('https://github.com/vjeux/download-file-sync');
// '<!DOCTYPE html><html lang="en"...'

That's it, now you can get back to writing awesome prototypes ;)

How does it work

Here's the full implementation:

module.exports = function(url) {
  return require('child_process')
    .execFileSync('curl', ['--silent', '-L', url], {encoding: 'utf8'});
}

As you can imagine, this is not web scale, but it works!

Current Tags

  • 1.0.4                                ...           latest (11 years ago)

5 Versions

  • 1.0.4                                ...           11 years ago
  • 1.0.3                                ...           11 years ago
  • 1.0.2                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 19
Today 0
This Week 0
This Month 15
Last Day 0
Last Week 0
Last Month 4
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE