Add deprecated shims for invalid args to node path functions

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Max Brunsfeld
2016-08-24 13:19:42 -07:00
committed by Thomas Johansen
parent e7444b1ebe
commit c876fd76f8

View File

@@ -1,5 +1,39 @@
const path = require('path')
const electron = require('electron')
const dirname = path.dirname
path.dirname = function (path) {
if (typeof path !== 'string') {
path = '' + path
const Grim = require('grim')
Grim.deprecate('Argument to `path.dirname` must be a string')
}
return dirname(path)
}
const extname = path.extname
path.extname = function (path) {
if (typeof path !== 'string') {
path = '' + path
const Grim = require('grim')
Grim.deprecate('Argument to `path.extname` must be a string')
}
return extname(path)
}
const basename = path.basename
path.basename = function (path, ext) {
if (typeof path !== 'string' || (ext !== undefined && typeof ext !== 'string')) {
path = '' + path
const Grim = require('grim')
Grim.deprecate('Arguments to `path.basename` must be strings')
}
return basename(path, ext)
}
electron.ipcRenderer.sendChannel = function () {
const Grim = require('grim')
Grim.deprecate('Use `ipcRenderer.send` instead of `ipcRenderer.sendChannel`')