wokim / node-perforce

A simple library for perforce
MIT License
14 stars 13 forks source link

Multi line description when editing is not working #24

Open ctitof137 opened 5 years ago

ctitof137 commented 5 years ago

Hi, I am trying to edit a file with a description that is on multiple line. As this is getting picked up by some automated tools, i need to make sure it is on multiple line.

The following will return an error: _``` build_description="\ First Line\n\ Second Line\n\ Third Line\n\ "

p4.changelist.create({description: build_description}, function (err, changelist) { if (err) return console.log(err);



I was able to fix it locally. I have never contributed so I'm not sure what the process is so here is what I did to fix it:
`
  if (ob.stdin.length > 0) {
    ob.stdin.forEach(function (line) {
      // for multline field, the first line goes in as is, and the following need to start with a tab
      let multiline = line.split('\n')
      child.stdin.write(multiline[0] + '\n');
      multiline.shift();
      multiline.forEach(function (l) {
        child.stdin.write('\t' + l + '\n');
      });
    });
    child.stdin.emit('end');
  }
`
Bascially, I followed how they are doing with the files for multilines, which is to add a tab for each new line that belongs to the same tag.
RecklessWave commented 6 months ago

I've integrated your fix into this fork of the project:

https://github.com/RecklessWave/reckless-node-perforce https://www.npmjs.com/package/reckless-node-perforce