[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: cli #31

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use the correct readme
  • Loading branch information
Zn4rK committed Nov 26, 2023
commit 3a5e77a8125287302d27a5aa9848ddd5cc90a928
5 changes: 0 additions & 5 deletions .changeset/spotty-timers-fix.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/stale-starfishes-warn.md

This file was deleted.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "navita",
"version": "0.0.3",
"version": "0.0.4",
"description": "Navita CLI",
"keywords": [
"navita",
Expand Down
11 changes: 3 additions & 8 deletions scripts/build/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createDeclaration } from "./createDeclaration";
import { createPackageJson as createPackageJsonString } from "./createPackageJson";
import { extractPathsFromExports } from "./extractPathsFromExports";
import { transpile } from "./transpile";
import { checkFileExists } from "./checkFileExists";

const isDevMode = process.argv.includes("--dev");
const cwd = process.cwd();
Expand Down Expand Up @@ -35,19 +36,13 @@ async function main() {
const isCjs = files.find((file) => file.endsWith(".cjs"));

const promises: Promise<unknown>[] = [];

const excludedFiles = ['package.json'];

promises.push(
copyFiles([
// Try with the local README.md first, then the root README.md
{
from: "./README.md",
to: path.resolve(outDir, "README.md"),
},
{
from: "../../README.md",
to: path.resolve(outDir, "README.md"),
from: await checkFileExists("./README.md") ? "./README.md" : '../../README.md',
to: path.resolve(outDir, "README.md")
},
...files
.filter((file) => !file.match(/\.([cm])?js|ts$/))
Expand Down
7 changes: 7 additions & 0 deletions scripts/build/src/checkFileExists.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as fs from "fs";

export function checkFileExists(file: string) {
return fs.promises.access(file, fs.constants.F_OK)
.then(() => true)
.catch(() => false)
}
3 changes: 1 addition & 2 deletions scripts/build/src/copyFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export async function copyFiles(files: { from: string; to: string }[]) {
promises.push(
fs.promises
.mkdir(path.dirname(to), { recursive: true })
.then(() => fs.promises.copyFile(from, to, fs.constants.COPYFILE_EXCL))
.catch(() => undefined)
.then(() => fs.promises.copyFile(from, to))
);
}

Expand Down
Loading