forked from lerna/lerna
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
48 lines (38 loc) · 1.29 KB
/
Copy pathinit.js
File metadata and controls
48 lines (38 loc) · 1.29 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
var chalk = require("chalk");
var path = require("path");
var fs = require("fs");
module.exports = function (cmd, cwd) {
var version = require("../package.json").version;
console.log();
console.log(chalk.bold("Lerna " + cmd + " v" + version));
console.log();
var config = {};
config.packagesLoc = path.join(cwd, "packages");
if (!fs.existsSync(config.packagesLoc)) {
console.log("Creating packages folder.");
fs.mkdirSync(config.packagesLoc);
}
config.packageLoc = path.join(cwd, "package.json");
if (!fs.existsSync(config.packageLoc)) {
console.log("Creating package.json");
fs.writeFileSync(config.packageLoc, JSON.stringify({
private: true,
dependencies: {
lerna: "^" + version,
}
}, null, " "));
}
config.versionLoc = path.join(cwd, "VERSION");
if (fs.existsSync(config.versionLoc)) {
config.currentVersion = fs.readFileSync(config.versionLoc, "utf8").trim();
} else {
console.log("Creating VERSION file.");
fs.writeFileSync(config.versionLoc, "0.0.0");
config.currentVersion = "0.0.0";
}
console.log("Current version: " + config.currentVersion);
console.log("Version file location: " + config.versionLoc);
console.log("Packages location: " + config.packagesLoc);
console.log();
return config;
};