Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
imcotton committed Aug 8, 2024
1 parent 6486ce4 commit 8252cf5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Input source is reading from `stdin`.

### Built-in Presets

- `--all`
- `--lodash`: pkg naming starts by `lodash.` or equals to `lodash`
- `--nolyfill`: list of names from https://github.com/SukkaW/nolyfill (**1.0.34**)
- `--relief`: list of names from https://github.com/es-tooling/module-replacements (**2.3.2**)
Expand Down
2 changes: 2 additions & 0 deletions src/cli/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Usage:
Builtin Presets:
--all
--lodash
--nolyfill (via SukkaW/nolyfill v1.0.34)
Expand Down
4 changes: 4 additions & 0 deletions src/cli/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export function parse (args: Iterable<string>): Flags {
short: 'v',
},

all: {
type: 'boolean',
},

// presets

lodash: {
Expand Down
2 changes: 2 additions & 0 deletions src/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface Flags {

invert?: boolean;

all?: boolean;

lodash?: boolean;

nolyfill?: boolean;
Expand Down
22 changes: 18 additions & 4 deletions src/presets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { nolyfill };
import * as relief from './relief.ts';
export { relief };

import type { Predicate } from '../common.ts';
import { type Predicate, or } from '../common.ts';



Expand All @@ -17,6 +17,8 @@ export type Param = Partial<Readonly<Record<Toggle, boolean | undefined>>>;

export type Toggle =

| 'all'

| 'lodash'
| 'nolyfill'

Expand All @@ -31,21 +33,33 @@ export type Toggle =



const on = (t: Toggle) => (p: Param) => p[t] === true;

const on_all = on('all');

const all_OR_lodash = or(on_all, on('lodash'));
const all_OR_nolyfill = or(on_all, on('nolyfill'));
const all_OR_relief = or(on_all, on('relief'));





export function * gen_presets (

param: Param,

): Iterable<Predicate<string>> {

if (param.lodash === true) {
if (all_OR_lodash(param)) {
yield lodash.check;
}

if (param.nolyfill === true) {
if (all_OR_nolyfill(param)) {
yield nolyfill.check;
}

if (param.relief === true) {
if (all_OR_relief(param)) {

yield * [
relief.native_check,
Expand Down

0 comments on commit 8252cf5

Please sign in to comment.