-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fd320a
commit 77e021d
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package fs | ||
|
||
import ( | ||
lib_fs "github.com/projectdiscovery/nuclei/v2/pkg/js/libs/fs" | ||
|
||
"github.com/dop251/goja" | ||
"github.com/projectdiscovery/nuclei/v2/pkg/js/gojs" | ||
) | ||
|
||
var ( | ||
module = gojs.NewGojaModule("nuclei/fs") | ||
) | ||
|
||
func init() { | ||
module.Set( | ||
gojs.Objects{ | ||
// Functions | ||
"ListDir": lib_fs.ListDir, | ||
"ReadFile": lib_fs.ReadFile, | ||
"ReadFileAsString": lib_fs.ReadFileAsString, | ||
|
||
// Var and consts | ||
|
||
// Types (value type) | ||
|
||
// Types (pointer type) | ||
}, | ||
).Register() | ||
} | ||
|
||
func Enable(runtime *goja.Runtime) { | ||
module.Enable(runtime) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @module fs | ||
*/ | ||
|
||
/** | ||
* @method | ||
* @name ListDir | ||
* @param {string} path - The path of the directory. | ||
* @param {string} itemType - The type of the item (values => all/file/dir) | ||
* @throws {Error} If an error occurred while listing the directory. | ||
* @example | ||
* // Usage of ListDir | ||
* let m = require('nuclei/fs'); | ||
* let files = ListDir('helpers', 'file'); | ||
*/ | ||
function ListDir(path, itemType) { | ||
// implemented in go | ||
} | ||
|
||
/** | ||
* @method | ||
* @name ReadFile | ||
* @param {string} path - The path of the file. | ||
* @throws {Error} If an error occurred while reading the file. | ||
* @return {Buffer} The content of the file. | ||
* @example | ||
* // Usage of ReadFile | ||
* let m = require('nuclei/fs'); | ||
* let content = ReadFile('helpers/usernames.txt'); | ||
*/ | ||
function ReadFile(path) { | ||
// implemented in go | ||
} | ||
|
||
/** | ||
* @method | ||
* @name ReadFileAsString | ||
* @param {string} path - The path of the file. | ||
* @throws {Error} If an error occurred while reading the file. | ||
* @return {string} The content of the file as a string. | ||
* @example | ||
* // Usage of ReadFileAsString | ||
* let m = require('nuclei/fs'); | ||
* let content = ReadFileAsString('helpers/usernames.txt'); | ||
*/ | ||
function ReadFileAsString(path) { | ||
// implemented in go | ||
} | ||
|
||
module.exports = { | ||
ListDir: ListDir, | ||
ReadFile: ReadFile, | ||
ReadFileAsString: ReadFileAsString, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters