Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

lewagon/nightmare-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NightmareJS Boilerplate bot

You need Node.js and Phantom.js installed on your computer. You also need git, a Heroku account and the Heroku toolbelt.

Version

This boilerplate works with version 1.8 of Nightmare JS, not the newest 2.x version. To get the documentation of the 1.8 version, follow this link.

Getting started

First, download this repository ZIP.

Unzip it, and move the folder from your Download repository to where you usually code. Open the folder in the terminal (you can cd to it). Once in that folder, run:

$ git init
$ git commit -m "Starting from @lewagon's boilerplate"
$ npm install

We need this folder to be a git repository as we're going to deploy it to Heroku.

You can push this repo to GitHub if you wish to share your work or make a backup. Just go to this page. You can also use the Mac client or the Windows client.

Start coding

Open script.js in Sublime Text, and write some JavaScript code. You can then test your script with the terminal:

$ node script.js
# Or for more debugging power:
$ DEBUG=nightmare node script.js

When you are happy with your code, do not forget to commit it!

$ git add script.js
$ git commit -m "A description of what I just did."

(Take 10 seconds to think of meaningful commit messages, it's very important)

Deploy and run on Heroku

First create a Heroku app for your bot.

$ heroku create --region=eu --buildpack=https://github.com/ddollar/heroku-buildpack-multi.git

Then, to deploy it (after some commits), just run:

$ git push heroku master

To run the bot on Heroku, just prefix the command you run locally with heroku run. For instance, you get:

$ heroku run node script.js