Skip to content

Commit

Permalink
fix(cross-env): modify the flag installCrossPlatform to disableCrossP…
Browse files Browse the repository at this point in the history
…latform

* Angular Schematics CLI do not parse boolean with explicit arguments
(like `--flag false` or `--flag true`, see
angular/angular-cli#12150). It only detects
whether the flag is present or not.
  • Loading branch information
fcruzel committed Jan 9, 2021
1 parent 2be0001 commit af3d717
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ All available flags:
|  `postcssScssVersion` | The postcss-scss version to be installed. | `string` | `^3.0.4` |
|  `skipTailwindInit` | Skip initializing Tailwind. | `boolean` | `false` |
|  `tailwindVersion` | The Tailwind version to be installed. | `string` | `^2.0.1` |
|  `installCrossPlatform` | Set the build:prod script to be cross-platform. | `boolean` | `true` |
|  `disableCrossPlatform` | Set the build:prod script to be only UNIX compatible. | `boolean` | `false` |
|  `crossEnvVersion` | The cross-env version to be installed. | `string` | `^7.0.3` |

Advanced usage
Expand All @@ -83,10 +83,10 @@ ng add ngx-tailwind --tailwindVersion 1.9.6 --ngxBuildPlusVersion 10.1.1 --postc
```

By default, `cross-env` is added to the `build:prod` script to be able to set `NODE_ENV=prod` cross-platform.
If you want to override the default behavior, you can set the flag `--installCrossPlatform` to `false`:
If you want to override the default behavior, you can set the flag `--disableCrossPlatform`:

```bash
ng add ngx-tailwind --installCrossPlatform false
ng add ngx-tailwind --disableCrossPlatform
```

## Developing
Expand Down
8 changes: 4 additions & 4 deletions src/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function addDependencies(_options: Schema): Rule {
version: _options.ngxBuildPlusVersion,
});

if (_options.installCrossPlatform) {
if (!_options.disableCrossPlatform) {
addPackageJsonDependency(host, {
type: NodeDependencyType.Dev,
name: 'cross-env',
Expand Down Expand Up @@ -211,10 +211,10 @@ function addNpmScripts(_options: Schema): Rule {

const pkg = JSON.parse(buffer.toString());

if (_options.installCrossPlatform) {
pkg.scripts['build:prod'] = 'cross-env NODE_ENV=production ng build --prod';
} else {
if (_options.disableCrossPlatform) {
pkg.scripts['build:prod'] = 'NODE_ENV=production ng build --prod';
} else {
pkg.scripts['build:prod'] = 'cross-env NODE_ENV=production ng build --prod';
}

tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
Expand Down
6 changes: 3 additions & 3 deletions src/ng-add/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
"description": "The cross-env version to be installed.",
"default": "^7.0.3"
},
"installCrossPlatform": {
"disableCrossPlatform": {
"type": "boolean",
"description": "Set the build:prod script to be cross-platform.",
"default": true
"description": "Set the build:prod script to be only UNIX compatible.",
"default": false
}
}
}
4 changes: 2 additions & 2 deletions src/ng-add/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export interface Schema {
tailwindVersion: string;

/**
* Set the build:prod script to be cross-platform.
* Set the build:prod script to be only UNIX compatible.
*/
installCrossPlatform: boolean;
disableCrossPlatform?: boolean;

/**
* cross-env version.
Expand Down

0 comments on commit af3d717

Please sign in to comment.