forked from exercism/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathname-uniq
More file actions
executable file
·31 lines (24 loc) · 792 Bytes
/
Copy pathname-uniq
File metadata and controls
executable file
·31 lines (24 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env node
/**
* Run this script (from root directory): npx babel-node scripts/name-uniq
*
* This will run following checks:
*
* 1. All exercises have unique package names in their package.json files.
*/
const shell = require('shelljs');
const { packageFiles, registerExitHandler } = require('./helpers');
registerExitHandler();
const allNames = packageFiles.map(
(filePath) => JSON.parse(shell.cat(filePath).toString())['name']
);
// Check if all exercises have unique package names
const duplicates = allNames.filter((e, i) => allNames.indexOf(e) !== i);
if (duplicates.length !== 0) {
shell.echo(
`[Failure] Duplicate package names found: ${duplicates.join(', ')}`
);
shell.exit(1);
}
shell.echo('[Success] All package names are unique.');
shell.exit(0);