Modules can export function
Text in image:
D: > temp > onenote-to-html > work > scripts > modules > getContentafFile 'S index.js
2
6
10
const - fs- = - i le- system' ) ;
const getContentOfFi1e pathToFi1e
return fs. readFi1eSync(pathToFi1e,
'if (err) throa- err;
return data;
•utf-8' ,
err,
- data)
/ / const content getcontentofFi le(pathToF ile) ;
module. exports = - getContentOfF ile;l
Text in image:
D: > temp > önenote-to-html > work > scripts > 'S fle_splitter.js > getComtentC)fFile
console. log( el);
2
6
10
11
const
f s le- system' ) ;
const, cheerio
require( cheerio' );
getContentOfFi1e- = - require( . 'modules/ getContentOfF ile ' ) ;
const
master-F ilecontent -
getContentOfFi1e( . /.. /Notes/Zette1Kasten- ] .
const
$ cheerio. load(masterF ilecontent);
c onst
$( body/ YO div • ). each((index, -el) -
D;
Or object
Text in image:
O: > temp > onenote-to-html > work > scripts > modules > getContentafFile > JS index.js >
3
4
8
11
12
m
const fw=- require( • .file- system •
const getContentOfFi1e- = - pathToFi le
return fs. readFi1esync(pathToFi1e,
if (err) thro.' err;
return data;
module. exports -
utf-8' (err, -data)
/ (const content - - - getContentOfFi le(pathToF i le) ;
getcontentofFi1e: getcontentofFi1e
Text in image:
D: > temp > önenote-to-html > work > scripts > 'S fle_splitter.js >
console. log( el);
2
6
10
11
const
const
const
c onst
f s le- system' ) ;
const, cheerio
helpers =
require( cheerio' );
require( • . (modules/ getContentOfFi1e' ) ;
master-F ilecontent -
— helpers. getContentOfFi1e( . /.. /uotes/zettel-
$ cheerio. load(masterF ilecontent •
$( body/ YO div • ). each((index, -el) -
D;
NodeJS
How to use custom NodeJS modules?