Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Coffeescript Application Development Cookbook
  • Table Of Contents Toc
Coffeescript Application Development Cookbook

Coffeescript Application Development Cookbook

By : Hatfield
4.6 (5)
close
close
Coffeescript Application Development Cookbook

Coffeescript Application Development Cookbook

4.6 (5)
By: Hatfield

Overview of this book

If you are interested in developing modern applications, this book will help you leverage the vast JavaScript ecosystem while using an elegant language, helping you avoid the shortcomings of JavaScript.
Table of Contents (13 chapters)
close
close
12
Index

Archiving files and directories


In this recipe, we will look at creating archives of our files and directories.

Getting ready

We will be using the archiver NPM module. Install it with the following command:

npm install archiver --save

How to do it...

With the archiver module installed, we can use it to create a backup file of our entire workspace tree by following these steps:

  1. Load the fs and archiver modules:

    fs = require 'fs'
    archiver = require 'archiver'
    
  2. Create a write stream:

    output = fs.createWriteStream 'backup.zip'
    
  3. Create an instance of a ZIP archive:

    archive = archiver 'zip'
    
  4. Add event handlers to the stream and archive:

    output.on 'close', ->
      console.log "Total bytes: #{archive.pointer()}"
    
    archive.on 'error', (err) ->
      console.error err
    
  5. Set the archive's output pipe to our stream writer:

    archive.pipe output
    
  6. Perform the compression:

    archive.bulk
      expand: yes
      cwd: 'workspace'
      src: ['**']
      dest: 'src'
    archive.finalize()
    

How it works...

We start by requiring the fs and archiver...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Coffeescript Application Development Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon