From 10eba439a5f850c07e4e635845e2ae7640d60d21 Mon Sep 17 00:00:00 2001 From: Fabien CELLIER Date: Thu, 7 Apr 2022 17:33:17 +0200 Subject: [PATCH] Override os line endings --- README.md | 6 ++++++ async/index.js | 2 +- protractor/index.js | 2 +- v6/index.js | 2 +- v7/index.js | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 046a95b..f4017ce 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,12 @@ If you use TypeScript make sure you apply a different parser as parameter, e.g.: $ npx jscodeshift -t ./node_modules/@wdio/codemod/protractor --parser=tsx ./e2e/*.ts ``` +If you use a different line terminator from your os, you can override it as parameter, e.g.: + +```sh +$ npx jscodeshift -t ./node_modules/@wdio/codemod/async --printOptions='{\"lineTerminator\":\"\n\"}' ./e2e/ +``` + You can transform tests as well as config files, e.g.: ![Codemod Usage Example][example] diff --git a/async/index.js b/async/index.js index afe5b4a..b8a28a1 100644 --- a/async/index.js +++ b/async/index.js @@ -515,5 +515,5 @@ module.exports = function transformer(file, api, opts) { compilers.update(j, root, auto_compile_opts, opts); - return root.toSource(); + return root.toSource(opts.printOptions); } diff --git a/protractor/index.js b/protractor/index.js index 5f54f63..7727dc0 100644 --- a/protractor/index.js +++ b/protractor/index.js @@ -873,5 +873,5 @@ module.exports = function transformer(file, api, opts) { }) compilers.update(j, root, autoCompileOpts, opts) - return root.toSource() + return root.toSource(opts.printOptions) } diff --git a/v6/index.js b/v6/index.js index c8eaf8c..5231436 100644 --- a/v6/index.js +++ b/v6/index.js @@ -114,5 +114,5 @@ module.exports = function transformer(file, api, opts) { })) )) - return root.toSource() + return root.toSource(opts.printOptions) } diff --git a/v7/index.js b/v7/index.js index 059012a..7000b0a 100644 --- a/v7/index.js +++ b/v7/index.js @@ -29,5 +29,5 @@ module.exports = function transformer(file, api, opts) { )) compilers.update(j, root, autoCompileOpts, opts) - return root.toSource() + return root.toSource(opts.printOptions) }