Skip to content

Commit 68b64ae

Browse files
aleclarsonmateodelnorte
authored andcommitted
fix: look only in current directory (#19)
This allows a metarepo within a metarepo
1 parent e9c4f67 commit 68b64ae

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

bin/meta-init

+5-9
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ if (process.argv[2] === '--help') {
1111
return console.log(`\n usage:\n\n meta init\n`);
1212
}
1313

14-
let force = false;
14+
const metaPath = path.resolve('.meta');
1515

16-
if (process.argv[2] === '--force') {
17-
force = true;
16+
if (fs.existsSync(metaPath) && process.argv[2] !== '--force') {
17+
return console.error(`A .meta file already exists in ${process.cwd()}. Use --force to override.`);
1818
}
1919

20-
var meta = getMetaFile({ warn: false });
21-
22-
if (meta && !force) return console.error(`A .meta file already exists in ${process.cwd()}. User --force to overwrite.`);
23-
2420
const metaJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'support', '.meta')).toString());
2521

2622
if (fs.existsSync('./.gitslave')) {
@@ -35,10 +31,10 @@ if (fs.existsSync('./.gitslave')) {
3531

3632
console.log(`creating a .meta file in ${process.cwd()} with contents\n${metaString.trim()}`);
3733

38-
fs.writeFileSync(path.join(process.cwd(), '.meta'), metaString);
34+
fs.writeFileSync(metaPath, metaString);
3935
});
4036
} else {
4137
console.log(`creating a .meta file in ${process.cwd()}`);
4238

43-
fs.writeFileSync(path.join(process.cwd(), '.meta'), getMetaFile.format(metaJson));
39+
fs.writeFileSync(metaPath, getMetaFile.format(metaJson));
4440
}

0 commit comments

Comments
 (0)