Skip to content

Commit

Permalink
Fix writing path dependencies to manifest
Browse files Browse the repository at this point in the history
- Add path key
- Use relative path
  • Loading branch information
timhall committed Sep 10, 2019
1 parent 413f688 commit c30d20f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/manifest/dependency.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { manifestOk } from '../errors';
import has from '../utils/has';
import { isString } from '../utils/is';
import { extname, join, trailing } from '../utils/path';
import { extname, join, relative, trailing } from '../utils/path';
import { Version } from './version';

/*
Expand Down Expand Up @@ -113,15 +113,17 @@ export function isGitDependency(dependency: Dependency): dependency is GitDepend
return has(dependency, 'git');
}

export function formatDependencies(dependencies: Dependency[]): object {
export function formatDependencies(dependencies: Dependency[], dir: string): object {
const value: { [name: string]: any } = {};
dependencies.forEach(dependency => {
if (isRegistryDependency(dependency)) {
const { name, registry, version } = dependency;
value[name] = registry !== 'vba-blocks' ? { version, registry } : version;
} else if (isPathDependency(dependency)) {
const { name, path } = dependency;
value[name] = path;
let { name, path } = dependency;
path = relative(dir, path);

value[name] = { path };
} else {
const { name, git, tag, branch, rev } = dependency;
value[name] = { name, git };
Expand Down
4 changes: 2 additions & 2 deletions src/manifest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function formatManifest(manifest: Manifest, dir: string): object {
value.src = formatSrc(manifest.src, dir);

if (manifest.dependencies.length) {
value.dependencies = formatDependencies(manifest.dependencies);
value.dependencies = formatDependencies(manifest.dependencies, dir);
}
if (manifest.references.length) {
value.references = formatReferences(manifest.references);
Expand All @@ -218,7 +218,7 @@ export function formatManifest(manifest: Manifest, dir: string): object {
value['dev-src'] = formatSrc(manifest.devSrc, dir);
}
if (manifest.devDependencies.length) {
value['dev-dependencies'] = formatDependencies(manifest.devDependencies);
value['dev-dependencies'] = formatDependencies(manifest.devDependencies, dir);
}
if (manifest.devReferences.length) {
value['dev-references'] = formatReferences(manifest.devReferences);
Expand Down

0 comments on commit c30d20f

Please sign in to comment.