Skip to content

Commit 6611d53

Browse files
alexey-koranDuude92
authored andcommitted
fix: cjsToEsm.cjs, missing extension in require c.cjs, log message typo in c.cjs (AlreadyBored#620)
1 parent d771ace commit 6611d53

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/modules/cjsToEsm.cjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const path = require('path');
2+
const { release, version } = require('os');
3+
const { createServer: createServerHttp } = require('http');
4+
require('./files/c.cjs');
5+
6+
const random = Math.random();
7+
8+
let unknownObject;
9+
10+
if (random > 0.5) {
11+
unknownObject = require('./files/a.json');
12+
} else {
13+
unknownObject = require('./files/b.json');
14+
}
15+
16+
console.log(`Release ${release()}`);
17+
console.log(`Version ${version()}`);
18+
console.log(`Path segment separator is "${path.sep}"`);
19+
20+
console.log(`Path to current file is ${__filename}`);
21+
console.log(`Path to current directory is ${__dirname}`);
22+
23+
const myServer = createServerHttp((_, res) => {
24+
res.end('Request accepted');
25+
});
26+
27+
const PORT = 3000;
28+
29+
console.log(unknownObject);
30+
31+
myServer.listen(PORT, () => {
32+
console.log(`Server is listening on port ${PORT}`);
33+
console.log('To terminate it, use Ctrl+C combination');
34+
});
35+
36+
module.exports = {
37+
unknownObject,
38+
myServer,
39+
};
40+

src/modules/files/c.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
console.log('Hello from c.js!');
1+
console.log('Hello from c.cjs!');

0 commit comments

Comments
 (0)