Developing locally on a Mac, I have this as an npm script in package json:
npx #svgr/cli --template path/to/template.js --ext .tsx my-icon.svg
This works as expected.
However, the Azure DevOps pipeline build fails when this script is run with the message Unknown command line option: '--ext'
It's not running in a container, so I assume it's running in a windows environment and that has something to do with this error.
--ext tsx is a valid command line argument; like i said it works in a unix environment (*macbook pro)
Any idea how to get around it?
So far I've tried the extension to the config file, but that particular option is only available through the cli.
I had a similar problem, but with GitHub actions, and my solution was to use
./node_modules/.bin/svgr --template path/to/template.js --ext .tsx my-icon.svg
Not sure if it will work in your case, though.
Related
I'm trying to build a simple app that makes use of the google cloud vision api for image analysis using node, though can't workout how to build the auth step into a simple npm script.
To access my account I currently set my auth credentials in the terminal (a bash terminal though I'm on a windows pc) as below, and can then run my server.js file which calls the google api.
export GOOGLE_APPLICATION_CREDENTIALS="C:\Users\tim\01_animal_snap\my-key.json"
This clearly doesn't take that long to write out and works fine, but I'd love to simply run a command like npm run auth instead.
I tried putting the following into my package.json file:
"scripts": {
"auth": "export GOOGLE_APPLICATION_CREDENTIALS=\"C:\\Users\\tim\\01_animal_snap\\my-key.json\"",
But when I run the script I get the following error:
'export' is not recognized as an internal or external command,
operable program or batch file.
I thought this might be an issue with running the 'export' command in a bash environment on windows (maybe npm scrips get executed in cmd or powershell by default?) and so installed cross-env and changed my script to:
"scripts": {
"auth": "cross-env export GOOGLE_APPLICATION_CREDENTIALS=\"C:\\Users\\tim\\01_animal_snap\\my-key.json\"",
Though I'm still getting the same error about export not being recognised. How can I run this command using an npm script?
export is not required when cros-env is used.
Try with
"auth": "cross-env GOOGLE_APPLICATION_CREDENTIALS="c://..."
I have a React project and I configured a build process in a file named build.js. The file tree is as below:
File structure:
I added "node build.js" script to scripts in package.json. It works fine on MacOS. However when I try to run the same npm run build script in my Windows machine, I get an error which says: "The system cannot find the file specified." "node build.js" command works fine when I move the file outside of project, for example to desktop. However, it does not work in the project.
The error from console:
I searched for any similar problem, but could not find anything. Any help would be appreciated.
edit: I solved my problem. It sees the file but can't see the file which should be removed by script. I misunderstood the problem and this is a false alarm. Sorry.
I'm using Stencil.js to create a web component library and I'm heavily relying on E2E tests. As they're rather slow it becomes more and more cumbersome to run the entire test suite (using the Stencil.js CLI) while developing new components.
However, I'm not able to run single tests in my IDE (IntelliJ IDEA) or via command line. It works perfectly fine for unit tests though.
My Jest config looks like this:
module.exports = {
"roots": [
"<rootDir>/src"
],
"preset": "#stencil/core/testing"
}
When I try to run tests in a single file (jest --config jest.config.js --testPathPattern src/components/button/button.e2e.ts$)
it fails, because
newE2EPage() is only available from E2E tests, and ran with the --e2e cmd line flag.
newE2EPage() comes with Stencil.js and I don't know what Stencil.js's CLI does in the background. Furthermore, I cloned the Stencil.js repository, just to see if it is working with their E2E tests (https://github.com/ionic-team/stencil/tree/master/test/end-to-end) but it doesn't work either.
Any idea how I can configure Jest so that it's able to run Stencil.js-E2E tests from the command line?
The --e2e flag is used for the npm script in the package.json. To start e2e tests, you can add this in your package.json:
"scripts": {
"test:e2e": "stencil test --e2e"
}
And run npm run test:e2e. For a specific file, you add it at the end like this:
npm run test:e2e src/components/button/button.e2e.ts
For more info, see the StencilJS doc: https://stenciljs.com/docs/end-to-end-testing
i have the same problem. IntelliJ and 'Run' single 'it' didnt work.
newE2EPage() is only available from E2E tests, and ran with the --e2e cmd line flag.
when i run 'npm run test' everything will work fine. the difference is that npm run stencil before and only jest dont work.
here is the stencil jest dir https://github.com/ionic-team/stencil/tree/master/src/testing/jest aswell a config.
i found in here https://stenciljs.com/docs/testing-overview a VS-CODE run jest code but no Intellij setup.
im on the run to get the path of the current file to run stencil via npm and the path the e2e file. but i cant find the correct variable for the run config.
i hope we got this solved soon.
cheers
I am not a VS Code user, but in contrast to IntelliJ there is a launch.json for VSC to run single tests: https://github.com/ionic-team/stencil-site/pull/480
I have some script-Entries in my package.json.
For deploying an App via Fastlane to an appstore, I need to set enviroment-Variables for APPLE_ID or for the JSON-File of google-services.
This settings are individual per User (and maybe per Project).
I know, how to add an hardcoded ENV-Variable via package.json:
"ANDROID_closedBeta": "FASTLANE_JSON_KEY_FILE=`find $(pwd) -name release_manager.json` bundle exec fastlane android deploy_closedBeta",
But thats doesn't solve my Problem. I have created an File: ios_env and linux_env which exports some sensitive credentials.
If I run source linux_env, the variables are set and I can run fastlane without any issue via CLI-Command: fastlane android deploy_closedBeta
But if I try to run it via yarn or npm, this ENV will not found.
So I've tried to run source in front of the falstlane-command, but also didn't work:
"ANDROID_closedBeta": "`source ./linux_env` FASTLANE_JSON_KEY_FILE=`find $(pwd) -name release_manager.json` bundle exec fastlane android deploy_closedBeta",
How can I get the package.json-script to recognise my enviroment-Variables without the need to hardcode it into package.json?
I've found an ugly workaround... but would be glad if somebody could show me a better way to to:
In package.json I declare two settings. One which has the main Script which need the still received ENV-Variables, and one Script-entry that loads first the Enviroment and then run the main-Script-Task within this enviroment.
Hard to explain, easy to show... look at this:
"scripts": {
...
"IOS_internalTest": "source ./fastlane/ios_env && IOS_DEPLOY_TYPE=deploy_internalTest npm run IOS_runDeployment",
"IOS_betaTest": "source ./fastlane/ios_env && IOS_DEPLOY_TYPE=deploy_betaTest npm run IOS_runDeployment",
"IOS_runDeployment": "bundle exec fastlane ios $IOS_DEPLOY_TYPE",
...
}
First entry source my file, where all my ENV Exports are (like export BIMBOM=FooBar)
After finish, it executes npm run IOS_doInternalTest. Because it's run in the same shell-context, the ENV-Variables I've sourceed before, are still available.
Kudos to you, if you got an solution in an one-liner
My goal is to run mocha unit tests by Atom, which is installed on Windows and also my src code resides. this should work independently from my Meteor App which is running on a different (Linux) machine.
Basically my setup is like this:
I have my repo and sourcecode:
c:\Users\Me\repos\meteor
My tests are inside:
c:\Users\Me\repos\meteor\tests
I have Node:
c:\Program Files\nodejs
installed with "npm i -g mocha --save-dev"
And i try to use this package https://github.com/Tabcorp/atom-mocha-test-runner but i can switch to another package if necessary.
What I've tried so far:
I edited my settings for the atom-mocha-test-runner:
Mocha command: C:\Program Files\nodejs\node_modules\mocha\.bin\mocha
Mocha command: C:\Program Files\nodejs\npm mocha
But each time i try to run my test via dropdown menu (Run Mocha Test), i get this error:
Mocha Test Results:
Node binary: C:\Program Files\nodejs\node.exe
Root folder: C:\Source\Repos
Mocha command: undefined
Path to mocha: mocha
Debug-Mode: false
Test file: tests\unit\first.js
Selected test: should return url
Failed to run Mocha
spawn mocha ENOENT
Anyone know what i miss or do wrong?
Still having no idea about why the package isn't working, I'm going to give a cop-out answer. If we figure out how to make it work, you can accept that answer instead. process-palette gives you the ability to run highly specific command-line instructions from Atom commands. Here's an example of a command that runs mocha in the project path for the current file with the same hotkey and also conveniently organized into its own menu item:
The disadvantage of this approach is that you have to know how to use the external program yourself. Packages like mocha-test-runner are designed to remove that need from the user, but as we can see here, sometimes the package doesn't know what it needs to be doing. The disadvantage is mitigated by the fact that you only have to learn the command for long enough to set up the configuration to run it, and from that point on it's very easy.
Advantages versus other packages include the ability to precisely control what's going on. Say you have multiple top-level folders in the current project, and they have different test suites. A package like mocha-test-runner can get the path from the active file, or from the project. If the developer chose to grab the project path, then you're going to have trouble running individual test suites. With the configuration I've shared, the command will always be run in the absolute path of the current file's project folder, so the tests will be run for whichever file you're working on at the time.