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 Windows path handling #3

Merged
merged 7 commits into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
[*.{yml,json,md}]
indent_style = space

[*.md]
trim_trailing_whitespace = false
33 changes: 33 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
environment:
matrix:
- nodejs_version: "7"
- nodejs_version: "6"
- nodejs_version: "4.6"

max_jobs: 4
clone_depth: 1
branches:
only:
- master

version: "{build}"

install:
- ps: Install-Product node $env:nodejs_version
- npm -g install npm@latest
- set PATH=%APPDATA%\npm;%PATH%
- npm install

platform:
- x86
- x64

matrix:
fast_finish: true

build: off

test_script:
- node --version
- npm --version
- npm test
21 changes: 14 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ const p = require('path');
const revHash = require('rev-hash');
const sortKeys = require('sort-keys');

const SEP = '/';
let MANIFEST, FILEPATH;
const IGNORE = ['.png', 'jpg', '.jpeg', '.svg', '.gif', '.woff', '.ttf', '.eot'];
let MANIFEST;
let FILEPATH;

function fixPath(str) {
return str.replace(/\\+/g, SEP);
}

module.exports = function (fly) {
/**
Expand Down Expand Up @@ -51,7 +55,7 @@ module.exports = function (fly) {
}, opts);

// update known values
FILEPATH = p.resolve(opts.dest, opts.file);
FILEPATH = fixPath(p.resolve(opts.dest, opts.file));

// content to replace
if (!opts.trim || typeof opts.trim === 'string') {
Expand All @@ -60,17 +64,20 @@ module.exports = function (fly) {
opts.trim = str => str.replace(new RegExp(t, 'i'), '/');
}

let dir, old;
for (const f of files) {
// only if was revv'd
if (!f.orig) continue;
// strip a string from the `file.dir` path
let dir = p.relative(this.root, f.dir);
dir = fixPath(p.relative(this.root, f.dir));
// apply `opts.trim` func
dir = p.normalize(opts.trim(dir));
dir = fixPath(p.normalize(opts.trim(dir)));
// ensure no leading '/'
dir = dir.charAt(0) === '/' ? dir.substr(1) : dir;
// add pairing to manifest
MANIFEST[p.join(dir, f.orig)] = p.join(dir, f.base);
// reconstruct old path
old = fixPath(p.join(dir, f.orig));
// construct new; add pairing to manifest
MANIFEST[old] = fixPath(p.join(dir, f.base));
}

// alphabetically sort
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"rules": {
"require-yield": 1,
"no-loop-func": 1,
"one-var": 0,
"curly": 1
}
}
Expand Down