Download tsdx/src/utils.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tsdx/src/utils.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tsdx/src/utils.ts
-
curl -L -o utils.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tsdx/src/utils.ts
1.6 kB
| import fs from 'fs-extra'; | |
| import path from 'path'; | |
| import camelCase from 'camelcase'; | |
| import { PackageJson } from './types'; | |
| // Remove the package name scope if it exists | |
| export const removeScope = (name: string) => name.replace(/^@.*\//, ''); | |
| // UMD-safe package name | |
| export const safeVariableName = (name: string) => | |
| camelCase( | |
| removeScope(name) | |
| .toLowerCase() | |
| .replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, '') | |
| ); | |
| export const safePackageName = (name: string) => | |
| name | |
| .toLowerCase() | |
| .replace(/(^@.*\/)|((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''); | |
| export const external = (id: string) => | |
| !id.startsWith('.') && !path.isAbsolute(id); | |
| // Make sure any symlinks in the project folder are resolved: | |
| // https://github.com/facebookincubator/create-react-app/issues/637 | |
| export const appDirectory = fs.realpathSync(process.cwd()); | |
| export const resolveApp = function(relativePath: string) { | |
| return path.resolve(appDirectory, relativePath); | |
| }; | |
| // Taken from Create React App, react-dev-utils/clearConsole | |
| // @see https://github.com/facebook/create-react-app/blob/master/packages/react-dev-utils/clearConsole.js | |
| export function clearConsole() { | |
| process.stdout.write( | |
| process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H' | |
| ); | |
| } | |
| export function getReactVersion({ | |
| dependencies, | |
| devDependencies, | |
| }: PackageJson) { | |
| return ( | |
| (dependencies && dependencies.react) || | |
| (devDependencies && devDependencies.react) | |
| ); | |
| } | |
| export function getNodeEngineRequirement({ engines }: PackageJson) { | |
| return engines && engines.node; | |
| } | |