Skip to content

Instantly share code, notes, and snippets.

@entrptaher
Created March 15, 2017 09:51
Show Gist options
  • Save entrptaher/57752da677dda4af90b8565b1969aa37 to your computer and use it in GitHub Desktop.
Save entrptaher/57752da677dda4af90b8565b1969aa37 to your computer and use it in GitHub Desktop.
Maybe some not so professional way of debugging nightmare
var Nightmare = require('nightmare'),
path = require('path'), // ADD THIS
nightmare = Nightmare({
show: true,
alwaysOnTop: false,
webPreferences: {
preload: path.resolve('preload.js') // USE PATH.RESOLVE FUNCTION
}
});
nightmare
.goto('http://www.example.com')
.then(() => {
})
{
"name": "home",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"express": "^4.15.2",
"nightmare": "^2.10.0",
"watchr": "^3.0.1"
}
}
window.__nightmare = {};
__nightmare.ipc = require('electron').ipcRenderer;
// Import the watching library
var watchr = require('watchr')
var fs = require('fs');
// Define our watching parameters
var path = process.cwd()
function listener (changeType, fullPath, currentStat, previousStat) {
eval(fs.readFileSync(fullPath, 'utf8'));
}
function next (err) {
if ( err ) return console.log('watch failed on', path, 'with error', err)
console.log('watch successful on', path)
}
// Watch the path with the change listener and completion callback
var stalker = watchr.open("runMe.js", listener, next)
let bar = "foo"
console.log(bar)
debugger;
console.log(bar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment