This repository was archived by the owner on Jun 22, 2022. It is now read-only.
forked from exercism/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync
More file actions
executable file
·48 lines (42 loc) · 1.49 KB
/
Copy pathsync
File metadata and controls
executable file
·48 lines (42 loc) · 1.49 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env node
/**
* Run this script (from root directory): npx babel-node scripts/sync
*
* This script is used to copy the following files to all exercises and keep
* them in sync:
*
* - .eslintrc
* - babel.config.js
* - package.json (modified version)
* - .npmrc
*
* There is a CI step which checks that package.json in root & exercises match
* (see checksum script for more info).
*/
const shell = require("shelljs");
const assignment = shell.env["ASSIGNMENT"];
const helpers = require("./helpers");
const path = require("path");
function copyConfigForAssignment(assignment) {
const destination = path.join("exercises", assignment);
const assignmentPackageFilename = path.join(destination, "package.json");
const assignmentVersion = getAssignmentVersion(assignmentPackageFilename);
helpers.createExercisePackageJson(assignmentVersion);
shell.cat("exercise-package.json").to(assignmentPackageFilename);
shell.rm("exercise-package.json");
shell.cp("babel.config.js", destination);
shell.cp(".eslintrc", destination);
shell.cp(".npmrc", destination);
}
function getAssignmentVersion(assignmentPackageFilename) {
const packageFile = shell.cat(assignmentPackageFilename).toString();
const packageJson = JSON.parse(packageFile);
return packageJson["version"];
}
if (assignment) {
shell.echo("Syncing " + assignment + "...");
copyConfigForAssignment(assignment);
} else {
shell.echo("Syncing all assignments...");
helpers.assignments.forEach(copyConfigForAssignment);
}