MCPcopy Index your code
hub / github.com/QwikDev/qwik / createSystem

Function createSystem

packages/qwik-city/src/static/node/node-system.ts:11–92  ·  view source on GitHub ↗
(opts: StaticGenerateOptions)

Source from the content-addressed store, hash-verified

9
10/** @public */
11export async function createSystem(opts: StaticGenerateOptions) {
12 patchGlobalThis();
13
14 const createWriteStream = (filePath: string) => {
15 return fs.createWriteStream(filePath, {
16 flags: 'w',
17 });
18 };
19
20 const NS_PER_SEC = 1e9;
21 const MS_PER_NS = 1e-6;
22
23 const createTimer = () => {
24 const start = process.hrtime();
25 return () => {
26 const diff = process.hrtime(start);
27 return (diff[0] * NS_PER_SEC + diff[1]) * MS_PER_NS;
28 };
29 };
30
31 const createLogger = async () => {
32 return {
33 debug: opts.log === 'debug' ? console.debug.bind(console) : () => {},
34 error: console.error.bind(console),
35 info: console.info.bind(console),
36 };
37 };
38
39 const outDir = normalizePath(opts.outDir);
40
41 const basePathname = opts.basePathname || '/';
42 const basenameLen = basePathname.length;
43
44 const getRouteFilePath = (pathname: string, isHtml: boolean) => {
45 pathname = decodeURIComponent(pathname.slice(basenameLen));
46 if (isHtml) {
47 if (!pathname.endsWith('.html')) {
48 if (pathname.endsWith('/')) {
49 pathname += 'index.html';
50 } else {
51 pathname += '/index.html';
52 }
53 }
54 } else {
55 if (pathname.endsWith('/')) {
56 pathname = pathname.slice(0, -1);
57 }
58 }
59 return join(outDir, pathname);
60 };
61
62 const getDataFilePath = (pathname: string) => {
63 pathname = decodeURIComponent(pathname.slice(basenameLen));
64 if (pathname.endsWith('/')) {
65 pathname += 'q-data.json';
66 } else {
67 pathname += '/q-data.json';
68 }

Callers 2

generateFunction · 0.90
index.tsFile · 0.90

Calls 3

patchGlobalThisFunction · 0.90
normalizePathFunction · 0.90
createNodeMainProcessFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…