Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [DEP0016] DeprecationWarning: 'GLOBAL' is deprecated, use 'global' #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions magic-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,22 @@ Object.defineProperty(global, '__func', {
}
});

/** return base path of project */
/** return base path of project */
Object.defineProperty(global, '__base', {
get: function(){
return process.cwd();
return process.cwd();
}
});

/** returns filename, a colon, and line number when placing this in your code: __fili */
Object.defineProperty(global, '__fili', {
get: function(){
filid = ':'
if ( typeof GLOBAL.__filid !== 'undefined' && GLOBAL.__filid )
if ( typeof global.__filid !== 'undefined' && global.__filid )
{
filid = GLOBAL.__filid;
filid = global.__filid;
}

return __stack[1].getFileName() + filid + __stack[1].getLineNumber();
}
});

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magic-globals",
"version": "0.9.1",
"version": "0.9.2",
"description": "Magic Globals, ex. `__line` and `__func`. Similar to Magic Constants in PHP",
"main": "magic-globals.js",
"scripts": {
Expand Down
14 changes: 7 additions & 7 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* @example node ./tests/index.js
*/
*/

require('../magic-globals');
o = console.log


o('*** NOT INSIDE A FUNCTION ***')
o('__file: ' + __file)
o('__file: ' + __file)
o('__line: ' + __line)
o('__fili: ' + __fili)
o('__ext: ' + __ext)
o('__ext: ' + __ext)
o('__base: ' + __base)
o('__filename: ' + __filename)
o('__dirname: ' + __dirname)
Expand All @@ -19,10 +19,10 @@ o('__stack: ' + __stack)

function someFunction() {
o('\n*** INSIDE A FUNCTION ***')
o('__file: ' + __file)
o('__file: ' + __file)
o('__line: ' + __line)
o('__fili: ' + __fili)
o('__ext: ' + __ext)
o('__fili: ' + __fili)
o('__ext: ' + __ext)
o('__base: ' + __base)
o('__filename: ' + __filename)
o('__dirname: ' + __dirname)
Expand All @@ -41,6 +41,6 @@ o('\n*** CHILD COMMANDS ***')
// default __fili useful for copypaste to edit in Sublime. To make things a smidge easier in vim, you can set the __fili delimiter
o('__fili for sublime text users:')
o(__fili)
GLOBAL.__filid = ' +'
global.__filid = ' +'
o('__fili for vim users:')
o(__fili)
14 changes: 7 additions & 7 deletions tests/some.index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* @example node ./tests/index.js
*/
*/

require('../magic-globals');
o = console.log


o('*** NOT INSIDE A FUNCTION ***')
o('__file: ' + __file)
o('__file: ' + __file)
o('__line: ' + __line)
o('__fili: ' + __fili)
o('__ext: ' + __ext)
o('__ext: ' + __ext)
o('__base: ' + __base)
o('__filename: ' + __filename)
o('__dirname: ' + __dirname)
Expand All @@ -19,10 +19,10 @@ o('__stack: ' + __stack)

function someFunction() {
o('\n*** INSIDE A FUNCTION ***')
o('__file: ' + __file)
o('__file: ' + __file)
o('__line: ' + __line)
o('__fili: ' + __fili)
o('__ext: ' + __ext)
o('__fili: ' + __fili)
o('__ext: ' + __ext)
o('__base: ' + __base)
o('__filename: ' + __filename)
o('__dirname: ' + __dirname)
Expand All @@ -41,6 +41,6 @@ o('\n*** CHILD COMMANDS ***')
// default __fili useful for copypaste to edit in Sublime. To make things a smidge easier in vim, you can set the __fili delimiter
o('__fili for sublime text users:')
o(__fili)
GLOBAL.__filid = ' +'
global.__filid = ' +'
o('__fili for vim users:')
o(__fili)