Skip to content

Commit

Permalink
chore: Replace cwd with path.resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
cansuaa committed Aug 9, 2024
1 parent 804345c commit 06076fc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scripts/docs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import path from "node:path";
import process from "node:process";

import { documentComponents, documentTestUtils } from "@cloudscape-design/documenter";

import { dashCase, listPublicDirs, writeSourceFile } from "./utils.js";
const cwd = process.cwd();

const publicDirs = listPublicDirs("src");
const targetDir = "lib/components/internal/api-docs";

const importedCoreComponents = ["icon"];

componentDocs();
testUtilDocs();

Expand All @@ -23,13 +23,16 @@ function validatePublicFiles(definitionFiles) {
}

function getNodeModulesInterfacePath(componentName) {
return cwd + "/node_modules/@cloudscape-design/components/" + componentName + "/interfaces.d.ts";
return path.resolve("node_modules/@cloudscape-design/components", componentName, "interfaces.d.ts");
}

function componentDocs() {
const importedCoreComponents = ["icon"];
const nodeModulesInputFilePaths = importedCoreComponents.map(getNodeModulesInterfacePath);
const definitions = documentComponents(path.resolve("tsconfig.json"), "src/*/index.tsx", nodeModulesInputFilePaths);
const nodeModulesDependencyFilePaths = importedCoreComponents.map(getNodeModulesInterfacePath);
const definitions = documentComponents(
path.resolve("tsconfig.json"),
"src/*/index.tsx",
nodeModulesDependencyFilePaths,
);
const outDir = path.join(targetDir, "components");
const fileNames = definitions
.filter((definition) => {
Expand Down

0 comments on commit 06076fc

Please sign in to comment.