Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with Bash, Prettier and Glob #11

Open
JohanMouchet opened this issue Oct 11, 2020 · 1 comment
Open

Errors with Bash, Prettier and Glob #11

JohanMouchet opened this issue Oct 11, 2020 · 1 comment

Comments

@JohanMouchet
Copy link

Hi there,

Congratz for the work, this tool greatly facilitate migrations. 👏

I've noticed a few errors with the Sass script and would like to share with you.

I'm running this environment:

  • Windows 10
  • Node: v12.18.0
  • bash
  1. Not specifying node will prevent the script to be run by bash
    This could be general knowledge but might confuse a few Windows users and would benefit from being added to the README.

This is what it logs without it

>../sass-to-emotion/index.js ./my-folder/file.scss
'..' is not recognized as an internal or external command,
operable program or batch file.

and how to run it successfully:

>node ../sass-to-emotion/index.js ./my-folder/file.scss
  1. A local install of Prettier causes the script to fail

This is what it logs

>node ../sass-to-emotion/index.js ./my-folder/file.scss
Transforming 1 files...
prettier-eslint [ERROR]: prettier formatting failed due to a prettier error
c:\sass-to-emotion\node_modules\prettier-eslint\dist\index.js:147
      throw error;
      ^

ConfigError: Couldn't resolve parser "babylon"
    at resolveParser (C:\my-folder\node_modules\prettier\index.js:11343:15)
    at normalize$1 (C:\my-folder\node_modules\prettier\index.js:11438:18)
    at formatWithCursor (C:\my-folder\node_modules\prettier\index.js:15034:12)
    at C:\my-folder\node_modules\prettier\index.js:51620:12
    at Object.format (C:\my-folder\node_modules\prettier\index.js:51640:12)
    at prettify (c:\sass-to-emotion\node_modules\prettier-eslint\dist\index.js:137:31)
    at format (c:\sass-to-emotion\node_modules\prettier-eslint\dist\index.js:105:12)
    at module.exports (c:\sass-to-emotion\transform.js:682:10)
    at c:\sass-to-emotion\index.js:29:18
    at Array.map (<anonymous>)

Note: after uninstalling Prettier it still logs this non-blocking warning:

{ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.
  1. A glob selection with a wildcard causes the script to fail

This is what it logs

>node ../sass-to-emotion/index.js ./my-folder/**/*.scss
Transforming 1 files...
internal/fs/utils.js:230
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'C:/my-folder/**/*.scss'
    at Object.openSync (fs.js:458:3)
    at Object.readFileSync (fs.js:360:35)
    at c:\dev\sass-to-emotion\index.js:23:22
    at Array.map (<anonymous>)
    at c:\dev\sass-to-emotion\index.js:22:6
    at Object.<anonymous> (c:\sass-to-emotion\index.js:67:3)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:/my-folder/**/*.scss'
}
  1. The Import path rewriting is incorrect (......)
    Input:
@import "assets/styles/settings/_settings";

.className {
    color: $color-primary;
}

Output:

import { colorPrimary} from "......styles\variables";

export const className = css`
  color: ${colorPrimary};
`;

Let me know if you require more details

@albertstill
Copy link
Contributor

Hey mate... Thanks so much for the the detailed issue, and apologies for the late reply.

For 1. I have updated the README and explicitly added node prefix to the command so it's clear for all users including windows.

For 2. I have fixed this in the code and upgrade to the latest prettier-eslint.

For 3 and 4 it seems to be a windows thing, it's really tricky for me and my colleagues to fix as we all use macs and linux so don't even have the ability to debug. I know issue 4 will be around this function. If you wanted to try fix 4 the test suite is pretty good, just run npm test -- --watch with a new test with the input Sass above and you should be in a good position to fix it. Sorry I can't help for these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants