File tree 3 files changed +20
-4
lines changed
atom/common/api/lib/exports
3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 1
1
// Do not expose the internal modules to `require`.
2
- exports . hideInternalModules = function ( ) {
2
+ const hideInternalModules = function ( ) {
3
3
var globalPaths = require ( 'module' ) . globalPaths ;
4
4
if ( globalPaths . length === 3 ) {
5
5
@@ -11,6 +11,10 @@ exports.hideInternalModules = function() {
11
11
// Attaches properties to |exports|.
12
12
exports . defineProperties = function ( exports ) {
13
13
return Object . defineProperties ( exports , {
14
+ hideInternalModules : {
15
+ enumerable : true ,
16
+ value : hideInternalModules
17
+ } ,
14
18
15
19
// Common modules, please sort with alphabet order.
16
20
clipboard : {
Original file line number Diff line number Diff line change 16
16
def main ():
17
17
os .chdir (SOURCE_ROOT )
18
18
19
- # Disable old APIs
20
- os .environ ['ELECTRON_HIDE_INTERNAL_MODULES' ] = 'true'
21
-
22
19
config = 'D'
23
20
if len (sys .argv ) == 2 and sys .argv [1 ] == '-R' :
24
21
config = 'R'
Original file line number Diff line number Diff line change @@ -10,6 +10,21 @@ remote = require('electron').remote;
10
10
11
11
ref = remote . require ( 'electron' ) , app = ref . app , BrowserWindow = ref . BrowserWindow ;
12
12
13
+ describe ( 'electron module' , function ( ) {
14
+ it ( 'can prevent exposing internal modules to require' , function ( done ) {
15
+ const electron = require ( 'electron' ) ;
16
+ const clipboard = require ( 'clipboard' ) ;
17
+ assert . equal ( typeof clipboard , 'object' ) ;
18
+ electron . hideInternalModules ( ) ;
19
+ try {
20
+ require ( 'clipboard' ) ;
21
+ } catch ( err ) {
22
+ assert . equal ( err . message , 'Cannot find module \'clipboard\'' ) ;
23
+ done ( ) ;
24
+ }
25
+ } ) ;
26
+ } ) ;
27
+
13
28
describe ( 'app module' , function ( ) {
14
29
describe ( 'app.getVersion()' , function ( ) {
15
30
return it ( 'returns the version field of package.json' , function ( ) {
You can’t perform that action at this time.
0 commit comments