UNPKG

hapi.app

Version:

HAPI application generator

42 lines (33 loc) 1.16 kB
fs = require "fs" prompt = require "prompt" async = require "async" tools = require "../src/tools" update = -> checkArguments(arguments) [folderPath, callback] = arguments folderPath ?= process.cwd() tools.checkInHapiApp(folderPath) async.series [ (cb) -> bundleTotem(folderPath, cb), (cb) -> completeCommand(cb) ], callback or -> bundleTotem = (folderPath, cb) -> console.log "Bundling Totem ..." tools.bundleTotem folderPath, cb completeCommand = (cb) -> console.log "Your app folder has been updated." cb?() checkArguments = (args) -> unless correctNumberOfArguments(args) throw new Error "wrong number of arguments" unless callbackArgumentIsFunction(args) throw new Error "invalid argument: #{callbackArgument(args)}" callbackArgument = (args) -> args[1] correctNumberOfArguments = (args) -> 0 <= args.length < 3 callbackArgumentIsFunction = (args) -> return true if args.length < 2 typeof callbackArgument(args) is "function" module.exports.command = update module.exports.help = "update updates a HAPI app with the most recent Totem.js"