Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
fix(changeset): parse diff on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amtrack committed Jul 26, 2020
1 parent fda8ced commit dc8efa6
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 57 deletions.
16 changes: 1 addition & 15 deletions lib/cli/changeset.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ var Manifest = require('../manifest');
var path = require('path');
var fs = require('fs-extra');
var vinylFs = require('vinyl-fs');
var miss = require('mississippi')
var split = require('split2');
var mergeStream = require('merge-stream');

var doc = "Usage:\n" +
Expand Down Expand Up @@ -74,18 +72,6 @@ SubCommand.prototype.process = function(proc, callback) {
});

var stdin = proc.stdin
.pipe(split())
.pipe(miss.through.obj(function(line, enc, cb) {
if (line.indexOf('diff --git') == 0) {
if (this.diff) this.push(this.diff);
this.diff = line;
} else {
this.diff += '\n' + line;
}
cb();
}, function(cb) {
cb(null, this.diff);
}))
.pipe(Diff.stream({
ignoreWhitespace: !!self.opts['--ignore-whitespace']
}))
Expand All @@ -98,7 +84,7 @@ SubCommand.prototype.process = function(proc, callback) {
}))
.pipe(vinylFs.dest(deploymentPath))
.on('end', function() {
callback(null, "exported metadata container to " + path.relative(proc.cwd, deploymentPath));
return callback(null, "exported metadata container to " + path.relative(proc.cwd, deploymentPath));
});

};
2 changes: 1 addition & 1 deletion lib/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Diff.stream = function(opts) {
opts = opts || {};

return miss.through.obj(function(diff, enc, cb) {
var files = parseDiff(diff);
var files = parseDiff(diff.toString());

if (files.length <= 0) return cb();

Expand Down
4 changes: 2 additions & 2 deletions lib/metadata-file-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ MetadataFileContainer.prototype.diff = function(other) {
var added = new Manifest();
var modified = new Manifest();
var deleted = new Manifest();
var isDeleted = other === undefined || other.isNull() || !other.path || other.path === '/dev/null';
var isNew = self.path === undefined || self.isNull() || !self.path || self.path === '/dev/null';
var isDeleted = other === undefined || other.isNull() || !other.path || other.path === '/dev/null' || other.path === '\\dev\\null';
var isNew = self.path === undefined || self.isNull() || !self.path || self.path === '/dev/null' || self.path === '\\dev\\null';
var componentFrom = self.getComponent();
var componentTo = other.getComponent();
if (isDeleted && componentFrom) {
Expand Down
4 changes: 2 additions & 2 deletions lib/metadata-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ MetadataFile.prototype.diff = function(other) {
var added = new Manifest();
var modified = new Manifest();
var deleted = new Manifest();
var isDeleted = other === undefined || other.isNull() || !other.path || other.path === '/dev/null';
var isNew = self.path === undefined || self.isNull() || !self.path || self.path === '/dev/null';
var isDeleted = other === undefined || other.isNull() || !other.path || other.path === '/dev/null' || other.path === '\\dev\\null';
var isNew = self.path === undefined || self.isNull() || !self.path || self.path === '/dev/null' || self.path === '\\dev\\null';
var isModified = !self.isNull() && !other.isNull() && self.path === other.path;
var componentFrom = self.getComponent();
var componentTo = other.getComponent();
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.getFileExtension = function(filename) {
};

exports.isValidFilename = function(filename) {
if (filename === undefined || filename === null || filename === '' || filename === '/dev/null') {
if (filename === undefined || filename === null || filename === '' || filename === '/dev/null' || filename === '\\dev\\null') {
return false;
}
if (path.basename(filename).match(/.*-meta\.xml$/)) {
Expand All @@ -44,7 +44,7 @@ exports.isValidFilename = function(filename) {

exports.isValidMetaFilename = function(filename) {
var self = this;
if (filename === undefined || filename === null || filename === '' || filename === '/dev/null') {
if (filename === undefined || filename === null || filename === '' || filename === '/dev/null' || filename === '\\dev\\null') {
return false;
}
var metadataFilename = self.getMetadataFilenameForMetaFilename(filename);
Expand Down
34 changes: 0 additions & 34 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"mississippi": "^4.0.0",
"multimatch": "^4.0.0",
"parse-diff": "^0.7.0",
"split2": "^3.0.0",
"underscore": "^1.8.3",
"vinyl": "^2.0.0",
"vinyl-fs": "^3.0.0",
Expand Down

0 comments on commit dc8efa6

Please sign in to comment.