1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ const fs = require ( 'fs' ) ;
7
+ const path = require ( 'path' ) ;
8
+
9
+ function deleteRefs ( dir ) {
10
+ const files = fs . readdirSync ( dir ) ;
11
+ for ( let file of files ) {
12
+ const filePath = path . join ( dir , file ) ;
13
+ const stat = fs . statSync ( filePath ) ;
14
+ if ( stat . isDirectory ( ) ) {
15
+ deleteRefs ( filePath ) ;
16
+ } else if ( path . extname ( file ) === '.js' ) {
17
+ const content = fs . readFileSync ( filePath , 'utf8' ) ;
18
+ const newContent = content . replace ( / \/ \/ \# s o u r c e M a p p i n g U R L = [ ^ ] + .j s .m a p / , '' )
19
+ if ( content . length !== newContent . length ) {
20
+ console . log ( 'remove sourceMappingURL in ' + filePath ) ;
21
+ fs . writeFileSync ( filePath , newContent ) ;
22
+ }
23
+ } else if ( path . extname ( file ) === '.map' ) {
24
+ fs . unlinkSync ( filePath )
25
+ console . log ( 'remove ' + filePath ) ;
26
+ }
27
+ }
28
+ }
29
+
30
+ let location = path . join ( __dirname , '..' , 'lib' ) ;
31
+ console . log ( 'process ' + location ) ;
32
+ deleteRefs ( location ) ;
0 commit comments