Skip to content

Instantly share code, notes, and snippets.

View naorzr's full-sized avatar
:octocat:
Whatever matters

naorzr

:octocat:
Whatever matters
View GitHub Profile
@naorzr
naorzr / getAppRoot.ts
Last active April 23, 2020 11:35
Get application root in nodejs for windows and unix system
// Node version 12.0
// Typescript version 3.8
import fs from "fs";
import path from "path";
const getAppRoot = (curPath: string, rootIndicator = 'package.json'): string | Error=> {
if (curPath.length === 0 || curPath === path.sep) {
throw new Error(`Couldn't find root dir`)
} else if (fs.existsSync(path.join(curPath, rootIndicator))) {
return curPath

Hello World

This is content converted from Markdown!

Here's a JSON sample:

{
  "foo": "bar"
}
@naorzr
naorzr / test.html
Created January 13, 2023 15:51
Hello World Html
<html>
<head>
<style>
h1 {
font-family: Calibri;
}
</style>
</head>
<body>
<h1>Hello World!</h1>