Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 442e1bd

Browse files
author
Matt Loring
committed
Add support for Node.js v6
1 parent 225af35 commit 442e1bd

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ node_js:
33
- '0.12'
44
- '4'
55
- '5'
6+
- '6'
67
script:
78
- ./bin/run-test.sh -c

lib/v8debugapi.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
/** @const */ var vm = require('vm');
2020
/** @const */ var path = require('path');
21-
/** @const */ //var util = require('util');
21+
/** @const */ var semver = require('semver');
2222

2323
/** @const */ var state = require('./state.js');
2424
/** @const */ var logModule = require('@google/cloud-diagnostics-common').logger;
@@ -61,29 +61,23 @@ module.exports.create = function(logger_, config_, fileStats_) {
6161
var breakpoints = {};
6262
var listeners = {};
6363
var numBreakpoints = 0;
64-
var usePermanentListener = true;
64+
// Before V8 4.5, having a debug listener active disables optimization. To
65+
// deal with this we only activate the listener when there is a breakpoint
66+
// active, and remote it as soon as the snapshot is taken. Furthermore, 4.5
67+
// changes the API such that Debug.scripts() crashes unless a listener is
68+
// active. We use a permanent listener on V8 4.5+.
69+
var v8_version = /(\d+\.\d+\.\d+)\.\d+/.exec(process.versions.v8);
70+
if (!v8_version || v8_version.length < 2) {
71+
return null;
72+
}
73+
var usePermanentListener = semver.satisfies(v8_version[1], '>=4.5');
6574

6675
// Node.js v0.11+ have the runInDebugContext method that can be used to fetch
6776
// the API object.
6877
if (!vm.runInDebugContext) {
6978
return null;
7079
}
7180

72-
// Before V8 4.6, having a debug listener active disables optimization. To
73-
// deal with this we only activate the listener when there is a breakpoint
74-
// active, and remote it as soon as the snapshot is taken. Furthermore, 4.6
75-
// changes the API such that Debug.scripts() crashes unless a listener is
76-
// active. We use a permanent listener on V8 4.6+.
77-
var result = /(\d+)\.(\d+)\.\d+\.\d+/.exec(process.versions.v8);
78-
if (!result) {
79-
// malformed V8 version?
80-
return null;
81-
}
82-
if (parseInt(result[1], 10) < 4 ||
83-
parseInt(result[2], 10) < 5) {
84-
usePermanentListener = false;
85-
}
86-
8781
v8 = vm.runInDebugContext('Debug');
8882
logger = logger_;
8983
config = config_;

0 commit comments

Comments
 (0)