Skip to content

Commit

Permalink
Prepare release 1.0.0-pre.7 (#29)
Browse files Browse the repository at this point in the history
* Updated CHANGELOG and package.json for 1.0.0-pre.7 release.
* Small renames for correctness and consistency.
* Security audit fix by updating package-lock'd minimist and mkdirp
  • Loading branch information
usergenic authored Apr 10, 2020
1 parent 0f4ecf9 commit 11100a0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

<!-- ## Unreleased -->
<!-- Add new unreleased items here -->
## [1.0.0-pre.7] - 2020-04-09
- Added support for Windows paths (thanks, @andrewiggins)

## [1.0.0-pre.6] - 2019-08-06
- Fixed issue where syntax errors encountered in files would result in an empty response.
Expand Down
26 changes: 8 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "koa-node-resolve",
"version": "1.0.0-pre.6",
"version": "1.0.0-pre.7",
"description": "Koa middleware that transforms Node package specifiers to relative paths",
"main": "lib/koa-node-resolve.js",
"files": [
Expand Down
11 changes: 6 additions & 5 deletions src/support/path-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
*/
import {posix, sep as pathSeparator} from 'path';

const dirnameRegex = process.platform === 'win32' ? /[^\\]+$/ : /[^\/]+$/;
const filenameRegex = process.platform === 'win32' ? /[^\\]+$/ : /[^\/]+$/;

/**
* Similar to `path.dirname()` except includes trailing slash and for a
* path `/like/this/` will return `/like/this/` instead of `/like` since the
* trailing slash indicates `this` is a folder name not a file name.
* (`path.dirname('/like/this/')` returns `/like`.)
*/
export const dirname = (path: string): string => path.replace(dirnameRegex, '');
export const dirname = (path: string): string =>
path.replace(filenameRegex, '');

export const ensureLeadingDotInURL = (path: string): string =>
(path.startsWith('../') || path.startsWith('./')) ? path : './' + path;
Expand All @@ -32,12 +33,12 @@ export const ensureTrailingSlashInPath = (path: string): string =>
export const forwardSlashesOnlyPlease = (path: string): string =>
path.replace(/\\/g, '/');

export const getBaseUrl = (href: string): string => href.replace(/[^\/]+$/, '');
export const getBaseURL = (href: string): string => href.replace(/[^\/]+$/, '');

export const noLeadingSlashInURL = (href: string): string =>
href.replace(/^\//, '');

export const relativePathToUrl = (from: string, to: string): string =>
export const relativePathToURL = (from: string, to: string): string =>
ensureLeadingDotInURL(posix.relative(
getBaseUrl(forwardSlashesOnlyPlease(from)),
getBaseURL(forwardSlashesOnlyPlease(from)),
forwardSlashesOnlyPlease(to)));
4 changes: 2 additions & 2 deletions src/support/resolve-node-specifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import nodeResolve from 'resolve';

import {Logger} from './logger';

import {dirname, relativePathToUrl} from './path-utils';
import {dirname, relativePathToURL} from './path-utils';

export const resolveNodeSpecifier =
(modulePath: string, specifier: string, logger: Logger): string => {
Expand All @@ -35,7 +35,7 @@ export const resolveNodeSpecifier =
packageJson.main
})
});
const resolvedURL = relativePathToUrl(modulePath, dependencyPath);
const resolvedURL = relativePathToURL(modulePath, dependencyPath);
if (resolvedURL !== specifier) {
logger.debug &&
logger.debug(`Resolved Node module specifier "${specifier}" to "${
Expand Down

0 comments on commit 11100a0

Please sign in to comment.