Skip to content

Instantly share code, notes, and snippets.

@mattroyer
Created May 7, 2012 20:09
Show Gist options
  • Save mattroyer/2630077 to your computer and use it in GitHub Desktop.
Save mattroyer/2630077 to your computer and use it in GitHub Desktop.
Create a new Html5 document with a CoffeeScript command.
# Create a new Html5 document, by default called index.html
# If the user supplies a different name, it will use that
# name instead.
#
# Examples:
# C:\>coffee html.coffee
# => index.html
# File Created!
#
# C:\>coffee html.coffee myNewDoc.html
# => myNewDoc.html
# File Created!
fs = require 'fs'
html = '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<div>
</div>
</body>
</html>
'''
file = process.argv
fs.writeFile file[2] or 'index.html', html, (err) ->
throw err if err
console.log "File created!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment