Skip to content

Commit

Permalink
Merge pull request #96 from glacion/master
Browse files Browse the repository at this point in the history
Address deprecations.
  • Loading branch information
STRML authored Feb 18, 2019
2 parents 5facb48 + 53d5f9d commit 6900a30
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
21 changes: 9 additions & 12 deletions babel-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ const path = require('path');
const babel = require('@babel/core');
const fs = require('fs');
const os = require('os');
const util = require('util');
const fork = require('child_process').fork;
const execSync = require('child_process').execSync;
const commander = require('commander');
const debounce = require('lodash.debounce');
const isString = require('lodash.isstring');
const isArray = require('lodash.isarray');
const isRegExp = require('lodash.isregexp');

const RESTART_COMMAND = 'rs';
Expand All @@ -30,7 +28,7 @@ function collect(val, memo) {
// https://github.com/babel/babel/commit/0df0c696a93889f029982bf36d34346a039b1920
function regexify(val) {
if (!val) return new RegExp;
if (isArray(val)) val = val.join("|");
if (Array.isArray(val)) val = val.join("|");
if (isString(val)) return new RegExp(val || "");
if (isRegExp(val)) return val;
throw new TypeError("illegal type for regexify");
Expand All @@ -39,7 +37,7 @@ function regexify(val) {
function arrayify(val) {
if (!val) return [];
if (isString(val)) return (val ? val.split(',') : []);
if (isArray(val)) return val;
if (Array.isArray(val)) return val;
throw new TypeError("illegal type for arrayify");
};

Expand Down Expand Up @@ -213,7 +211,6 @@ function handleFileLoad(filename, callback) {
function killApp() {
if (childApp) {
const currentPipeFd = pipeFd;
const currentPipeFilename = pipeFilename;

let hasRestarted = false;
const restartOnce = () => {
Expand Down Expand Up @@ -299,7 +296,7 @@ function restartAppInternal() {
const runnerExecArgv = process.execArgv.slice();
if (program.debug) {
runnerExecArgv.push(typeof(program.debug) === 'boolean'
? `--debug`
? `--debug`
: `--debug=${program.debug}`
)
}
Expand All @@ -311,14 +308,14 @@ function restartAppInternal() {
if (program.inspect) {
// Somehow, the default port (2992) is being passed from the node command line. Wipe it out.
const inspectArg = typeof(program.inspect) === 'boolean'
? `--inspect`
? `--inspect`
: `--inspect=${program.inspect}`
runnerExecArgv.push(inspectArg);
}
// Support for --inspect-brk option
if (program.inspectBrk) {
const inspectBrkArg = typeof(program.inspectBrk) === 'boolean'
? `--inspect-brk`
const inspectBrkArg = typeof(program.inspectBrk) === 'boolean'
? `--inspect-brk`
: `--inspect-brk=${program.inspectBrk}`
runnerExecArgv.push(inspectBrkArg)
}
Expand All @@ -334,9 +331,9 @@ function restartAppInternal() {
watcher.add(relativeFilename);
}
handleFileLoad(filename, (source, sourceMap) => {
const sourceBuf = new Buffer(source || 0);
const mapBuf = new Buffer(sourceMap ? JSON.stringify(sourceMap) : 0);
const lenBuf = new Buffer(4);
const sourceBuf = new Buffer.from(source || '');
const mapBuf = new Buffer.from(sourceMap ? JSON.stringify(sourceMap) : 0);
const lenBuf = new Buffer.alloc(4);
if (pipeFd) {
try {
lenBuf.writeUInt32BE(sourceBuf.length, 0);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"chokidar": "^1.4.3",
"commander": "^2.9.0",
"lodash.debounce": "^4.0.8",
"lodash.isarray": "^4.0.0",
"lodash.isregexp": "^4.0.1",
"lodash.isstring": "^4.0.1",
"source-map-support": "^0.4.0"
Expand Down
4 changes: 2 additions & 2 deletions runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let sources = {};
let maps = {};

let pipeFd;
const BUFFER = new Buffer(10 * 1024);
const BUFFER = new Buffer.alloc(10 * 1024);

// Node by default uses '.js' loader to load all the files with unknown extensions
const DEFAULT_LOADER = require.extensions['.js'];
Expand All @@ -23,7 +23,7 @@ function readLength(fd) {

function readFileFromPipeSync(fd) {
let length = readLength(fd);
let result = new Buffer(0);
let result = new Buffer.alloc(0);
while (length > 0) {
const newBytes = fs.readSync(fd, BUFFER, 0, Math.min(BUFFER.length, length));
length -= newBytes;
Expand Down

0 comments on commit 6900a30

Please sign in to comment.