Skip to content

Commit

Permalink
scripts[patch]: Ability to add additional gitignore paths to lc config (
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored May 2, 2024
1 parent 9eede89 commit 3a79ec0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 12 additions & 1 deletion libs/langchain-scripts/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ const updateConfig = ({
requiresOptionalDependency,
/** @type {boolean} */
shouldTestExports,
/** @type {Array<string> | undefined} */
additionalGitignorePaths = [],
}) => {
const generatedFiles = generateFiles(entrypoints);
const filenames = Object.keys(generatedFiles);
Expand Down Expand Up @@ -468,10 +470,12 @@ const updateConfig = ({
fs.writeFileSync(filename, content);
});

const gitignorePaths = [...filenames, ...DEFAULT_GITIGNORE_PATHS, ...(additionalGitignorePaths ? additionalGitignorePaths : [])];

// Update .gitignore
fs.writeFileSync(
"./.gitignore",
`${filenames.join("\n")}\n${DEFAULT_GITIGNORE_PATHS.join("\n")}\n`
`${gitignorePaths.join("\n")}\n`
);

if (shouldTestExports) {
Expand Down Expand Up @@ -724,6 +728,11 @@ export function createEntrypoints({
* @type {boolean}
*/
shouldGenMaps,
/**
* Additional paths to add to the .gitignore file.
* @type {Array<string> | undefined}
*/
additionalGitignorePaths,
}) {
if (isPre) {
cleanGenerated({ entrypoints });
Expand Down Expand Up @@ -753,6 +762,7 @@ export function createEntrypoints({
deprecatedNodeOnly,
requiresOptionalDependency,
shouldTestExports,
additionalGitignorePaths,
});
}
}
Expand Down Expand Up @@ -850,6 +860,7 @@ async function main() {
absTsConfigPath: config.tsConfigPath,
isPre,
shouldGenMaps,
additionalGitignorePaths: config.additionalGitignorePaths,
});
}

Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@langchain/scripts",
"version": "0.0.12",
"version": "0.0.13",
"description": "Shared scripts for LangChain.js",
"type": "module",
"engines": {
Expand Down
6 changes: 6 additions & 0 deletions libs/langchain-scripts/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,10 @@ export interface LangChainConfig {
* @returns {string}
*/
abs: (relativePath: string) => string;
/**
* Additional paths to add to the gitignore file.
* @default undefined
* @type {string[]}
*/
additionalGitignorePaths?: string[];
}

0 comments on commit 3a79ec0

Please sign in to comment.