Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Fix windows!
Browse files Browse the repository at this point in the history
  • Loading branch information
MoOx committed Nov 10, 2017
1 parent 433c63d commit f858688
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/plugin-collector-files/src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import path from "path";

const debug = require("debug")("phenomic:plugin:collector-files");

const sep = "/";
function normalizeWindowsPath(value: string) {
return value.replace(/(\/|\\)+/g, "/");
return value.replace(/(\/|\\)+/g, sep);
}

export function getKey(name: string, json: PhenomicTransformResult): string {
Expand Down Expand Up @@ -106,14 +105,14 @@ export default function() {
name = normalizeWindowsPath(name);
const key = getKey(name, json);
const adjustedJSON = injectData(name, json);
const pathSegments = name.split(path.sep);
const pathSegments = name.split(sep);
const allPaths = pathSegments.reduce((acc, v) => {
acc.push(acc.length > 0 ? acc[acc.length - 1] + "/" + v : v);
acc.push(acc.length > 0 ? acc[acc.length - 1] + sep + v : v);
return acc;
}, []);
return Promise.all(
allPaths.map(pathName => {
const relativeKey = key.replace(pathName + "/", "");
const relativeKey = key.replace(pathName + sep, "");
const sortedKey = makeSortedKey(relativeKey, json);
debug(`collecting ${relativeKey} for path '${pathName}'`);
return Promise.all([
Expand Down

0 comments on commit f858688

Please sign in to comment.