Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jul 6, 2023
1 parent c72b896 commit df1e095
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ jobs:
- name: Coverage
run: redrun coverage
- name: Coveralls
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 1 addition & 3 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"extension": [
".mjs"
],
"extension": [".mjs"],
"check-coverage": false,
"all": true,
"exclude": [
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ export default {
'lint:env': () => ['putout .', {
CI: 1,
}],
'env:lint': () => [
env,
'putout .',
],
'env:lint': () => [env, 'putout .'],
'lint:no-env': async () => await cutEnv('lint:env'),
};
```
Expand Down
24 changes: 5 additions & 19 deletions bin/madrun.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node

import {createRequire} from 'module';
import {
dirname,
Expand All @@ -15,10 +16,7 @@ const require = createRequire(import.meta.url);

const {exit} = process;

const {
MADRUN_PWD,
MADRUN_NAME,
} = process.env;
const {MADRUN_PWD, MADRUN_NAME} = process.env;

const cwd = process.cwd();

Expand Down Expand Up @@ -59,10 +57,7 @@ if (version) {
}

if (init) {
const {
createMadrun,
patchPackage,
} = await import('./init.mjs');
const {createMadrun, patchPackage} = await import('./init.mjs');

fix = true;

Expand Down Expand Up @@ -180,18 +175,9 @@ async function getScript() {
async function putoutMadrun(dir, {fix}) {
const name = `${dir}/.madrun.js`;
const {runPutout} = await import('../lib/fix.mjs');

const {
readFile,
writeFile,
} = await import('fs/promises');

const {readFile, writeFile} = await import('fs/promises');
const data = await readFile(name, 'utf8');

const {
places,
code,
} = await runPutout(data);
const {places, code} = await runPutout(data);

if (fix)
await writeFile(name, code);
Expand Down
14 changes: 3 additions & 11 deletions lib/fix.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import putout, {
initReport,
} from 'putout';
import putout, {initReport} from 'putout';
import dumpFormatter from '@putout/formatter-dump';

const report = initReport();

export const runPutout = async (data, options) => {
const {
code,
places,
} = putout(data, {
const {code, places} = putout(data, {
printer: 'putout',
...options,
plugins: [
'madrun',
],
plugins: ['madrun'],
});

return {
Expand All @@ -25,4 +18,3 @@ export const runPutout = async (data, options) => {
}),
};
};

5 changes: 1 addition & 4 deletions lib/madrun.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ const parse = async (name, {scripts, opts, env, isParallel, cutEnv}) => {

const fn = jessy(key, scripts);

const {
line,
lineEnv,
} = await runScriptFn(fn);
const {line, lineEnv} = await runScriptFn(fn);

const cmd = addOpts(line, opts);

Expand Down
4 changes: 2 additions & 2 deletions lib/wildcard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

module.exports = (str) => {
const wildcard = '^' + str
const wildcard = `^${str
.replace('.', '\\.')
.replace('*', '.*')
.replace('?', '.?') + '$';
.replace('?', '.?')}$`;

return RegExp(wildcard);
};
6 changes: 1 addition & 5 deletions supported.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
[
".madrun.js",
".madrun.cjs",
".madrun.mjs"
]
[".madrun.js", ".madrun.cjs", ".madrun.mjs"]
16 changes: 3 additions & 13 deletions test/madrun.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ const {
cutEnv,
} = require('..');

const {
reRequire,
stopAll,
} = mockRequire;
const {reRequire, stopAll} = mockRequire;

test('madrun: run', async (t) => {
const lint = 'eslint lib';
Expand Down Expand Up @@ -127,11 +124,7 @@ test('madrun: series: opts', async (t) => {
'lint:bin': () => 'eslint bin',
};

const result = await run([
'lint:lib',
'lint:bin',
], '--fix', env, scripts);

const result = await run(['lint:lib', 'lint:bin'], '--fix', env, scripts);
const expected = 'eslint lib --fix && eslint bin --fix';

t.equal(result, expected);
Expand Down Expand Up @@ -254,10 +247,7 @@ test('madrun: run: env: first', async (t) => {
};

const scripts = {
lint: () => [
env,
'eslint lib',
],
lint: () => [env, 'eslint lib'],
};

const result = await run('lint', null, null, scripts);
Expand Down

0 comments on commit df1e095

Please sign in to comment.