Skip to content

Commit

Permalink
improve prepare-travis for windows core.autocrlf=false
Browse files Browse the repository at this point in the history
Taking the end of line from the current checked out travis file content so that the file should not get dirty/warning when working on windows with core.autocrlf=true or false.

Signed-off-by: Amiram Wingarten <amiram.wingarten@sap.com>
  • Loading branch information
amiramw authored and paul-marechal committed Jun 20, 2019
1 parent 89d2627 commit 95c4a28
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/prepare-travis
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ while (match = regexp.exec(yarnList)) {

const travisPath = path.resolve(__dirname, '../.travis.yml');
const content = fs.readFileSync(travisPath).toString();
// compute checked out travis line ending characters
const endOfLine = content[content.indexOf('\n') - 1] === '\r' ? '\r\n' : '\n';
const startIndex = content.indexOf('# start_cache_directories') + '# start_cache_directories'.length;
const endIndex = content.indexOf('# end_cache_directories');
const result = content.substr(0, startIndex) + os.EOL +
directories.sort((d, d2) => d.localeCompare(d2)).map(d => ` - ${d}${os.EOL}`).join('') +
const result = content.substr(0, startIndex) + endOfLine +
directories.sort((d, d2) => d.localeCompare(d2)).map(d => ` - ${d}${endOfLine}`).join('') +
content.substr(endIndex);
fs.writeFileSync(travisPath, result);

0 comments on commit 95c4a28

Please sign in to comment.