Skip to content

Commit def7994

Browse files
committed
Incorporate suggested fix for multiple inputs to changelist commands.
1 parent 0484dbc commit def7994

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
reckless-node-perforce
22
=============
33

4-
A simple library for perforce
4+
A simplified fork of node-perforce with vulnerable dependencies removed and fixed commands.
55

66
## Install
77

@@ -15,39 +15,46 @@ npm install reckless-node-perforce
1515
var p4 = require('reckless-node-perforce');
1616

1717
// create a new changelist
18-
p4.changelist.create({description: 'hello world'}, function (err, changelist) {
18+
p4.changelist.create({description: 'hello world'}, function (err, changelist)
19+
{
1920
if (err) return console.log(err);
2021
console.log('changelist:', changelist);
2122
});
2223

2324
// view changelist info
24-
p4.changelist.view({changelist: changelist}, function (err, view) {
25+
p4.changelist.view({changelist: changelist}, function (err, view)
26+
{
2527
if (err) return console.log(err);
2628
console.log(view);
2729
});
2830

2931
// edit changelist 1234
30-
p4.changelist.edit({changelist: 1234, description: 'hi world'}, function (err) {
32+
p4.changelist.edit({changelist: 1234, description: 'hi world'}, function (err)
33+
{
3134
if (err) return console.log(err);
3235
});
3336

3437
// delete changelist 1234
35-
p4.changelist.delete({changelist: 1234}, function (err) {
38+
p4.changelist.delete({changelist: 1234}, function (err)
39+
{
3640
if (err) return console.log(err);
3741
});
3842

3943
// add files into CL@1234
40-
p4.add({changelist: 1234, filetype: 'binary', files: ['*.bin']}, function(err) {
44+
p4.add({changelist: 1234, filetype: 'binary', files: ['*.bin']}, function(err)
45+
{
4146
if (err) return console.log(err);
4247
});
4348

4449
// revert files
45-
p4.revert({files: ['*.bin']}, function(err) {
50+
p4.revert({files: ['*.bin']}, function(err)
51+
{
4652
if (err) return console.log(err);
4753
});
4854

4955
// edit files
50-
p4.edit({files: ['*.js']}, function(err) {
56+
p4.edit({files: ['*.js']}, function(err)
57+
{
5158
if (err) return console.log(err);
5259
});
5360
```

index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,21 @@ function execP4(p4cmd, options, callback)
9696
if (stderr) return callback(new Error(stderr));
9797
return callback(null, stdout);
9898
});
99+
99100
if (ob.stdin.length > 0)
100101
{
101102
ob.stdin.forEach(function (line)
102103
{
103-
child.stdin.write(line + '\n');
104+
// for multi-line inputs, the first line goes in as is, and the following need to start with a tab
105+
let multiline = line.split('\n')
106+
child.stdin.write(multiline[0] + '\n');
107+
multiline.shift();
108+
multiline.forEach(function (theLine)
109+
{
110+
child.stdin.write('\t' + theLine + '\n');
111+
});
104112
});
113+
105114
child.stdin.end();
106115
}
107116
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reckless-node-perforce",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Simplified fork of node-perforce with vulnerable dependencies removed and fixed commands",
55
"main": "index.js",
66
"scripts": {},

0 commit comments

Comments
 (0)