Skip to content

Commit c59e8f2

Browse files
authored
Merge pull request #36 from cascornelissen/master
Fix #35: Base indentation of .npm-upgrade.json on package.json
2 parents 5dd0538 + 3a1754b commit c59e8f2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Config.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {resolve} from 'path';
22
import {writeFileSync} from 'fs';
33
import del from 'del';
4-
54
import _ from 'lodash';
5+
import detectIndent from 'detect-indent';
6+
import {loadPackageJson} from './packageUtils';
67

78
const PROJECT_CONFIG_FILENAME = '.npm-upgrade.json';
89

@@ -32,9 +33,12 @@ export default class Config {
3233
if (_.isEmpty(data)) {
3334
this.remove();
3435
} else {
36+
const {source: packageSource} = loadPackageJson();
37+
const {indent} = detectIndent(packageSource);
38+
3539
writeFileSync(
3640
this[path],
37-
JSON.stringify(data, null, 2)
41+
JSON.stringify(data, null, indent)
3842
);
3943
}
4044
} catch (err) {

0 commit comments

Comments
 (0)