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

fix: cannot use file path dependencies #1779

Merged
merged 6 commits into from
Apr 20, 2022
Merged
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
remove duplication
  • Loading branch information
Chriscbr committed Apr 20, 2022
commit 96ae6f0ce1167a92026b3e87268e56e948fc22ea
11 changes: 1 addition & 10 deletions src/javascript/node-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
readdirSync,
readJsonSync,
} from "fs-extra";
import * as semver from "semver";
import { resolve as resolveJson } from "../_resolve";
import { Component } from "../component";
import { DependencyType } from "../dependencies";
Expand All @@ -17,7 +16,7 @@ import { Project } from "../project";
import { isAwsCodeArtifactRegistry } from "../release";
import { Task } from "../task";
import { exec, isTruthy, sorted, writeFile } from "../util";
import { extractCodeArtifactDetails } from "./util";
import { extractCodeArtifactDetails, minVersion } from "./util";

const UNLICENSED = "UNLICENSED";
const DEFAULT_NPM_REGISTRY_URL = "https://registry.npmjs.org/";
Expand Down Expand Up @@ -1406,11 +1405,3 @@ function determineLockfile(packageManager: NodePackageManager) {

throw new Error(`unsupported package manager ${packageManager}`);
}

function minVersion(version: string): string | undefined {
if (semver.validRange(version)) {
return semver.minVersion(version)?.version;
} else {
return version;
}
}
9 changes: 9 additions & 0 deletions src/javascript/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as semver from "semver";
import { basename, dirname, extname, join, sep } from "path";

export function renderBundleName(entrypoint: string) {
Expand Down Expand Up @@ -32,3 +33,11 @@ export function extractCodeArtifactDetails(registryUrl: string) {
}
throw new Error("Could not get CodeArtifact details from npm Registry");
}

export function minVersion(version: string): string | undefined {
if (semver.validRange(version)) {
return semver.minVersion(version)?.version;
} else {
return version;
}
}
9 changes: 1 addition & 8 deletions test/javascript/node-package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Project } from "../../src";
import { NodePackage } from "../../src/javascript/node-package";
import * as util from "../../src/util";
import { mkdtemp, synthSnapshot, TestProject } from "../util";
import { minVersion } from "../../src/javascript/util";

/**
* Mocks a yarn install, writing to yarn.lock
Expand Down Expand Up @@ -103,14 +104,6 @@ function mockYarnInstall(
);
}

function minVersion(version: string): string | undefined {
if (semver.validRange(version)) {
return semver.minVersion(version)?.version;
} else {
return version;
}
}

afterEach(() => {
jest.resetAllMocks();
jest.restoreAllMocks();
Expand Down