Skip to content

Commit 40dcdce

Browse files
committed
feat(config): include config.syncpack of package.json
Closes #86
1 parent 6311999 commit 40dcdce

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ tree in the following places:
310310
or `.syncpackrc.cjs` file
311311
- a `syncpack.config.js` or `syncpack.config.cjs` CommonJS module exporting an
312312
object
313+
- a `config.syncpack` property in `package.json`
313314

314315
If you want to specify a path to a configuration file, overriding the discovered
315316
configuration file (if present), you can use the `--config` option.

src/lib/disk.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { cosmiconfigSync } from 'cosmiconfig';
2-
import { readFileSync, removeSync, writeFileSync } from 'fs-extra';
2+
import { isNonEmptyObject, isObject } from 'expect-more';
3+
import {
4+
readFileSync,
5+
removeSync,
6+
writeFileSync,
7+
readJsonSync,
8+
} from 'fs-extra';
39
import { sync as globSync } from 'glob';
10+
import { join } from 'path';
411
import { sync as readYamlSync } from 'read-yaml-file';
512
import type { SyncpackConfig } from '../constants';
613
import { CWD } from '../constants';
@@ -30,6 +37,11 @@ export const disk = {
3037
try {
3138
const result = configPath ? client.load(configPath) : client.search();
3239
if (result === null) {
40+
const rcPath = join(CWD, 'package.json');
41+
const pjson = readJsonSync(rcPath, { throws: false });
42+
const rcConfig = pjson?.config?.syncpack;
43+
console.log(rcConfig);
44+
if (isNonEmptyObject(rcConfig)) return rcConfig;
3345
verbose('no config file found');
3446
return {};
3547
}

0 commit comments

Comments
 (0)