-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathtasks.js
45 lines (36 loc) · 1.08 KB
/
tasks.js
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
const { join, normalize } = require('path');
const fs = require('fs-extra');
const { paths, outputDirectory } = require('./config');
exports.clean = async () => {
await fs.emptyDir(outputDirectory);
};
exports.updateManifestVersion = async () => {
const [packageJson, manifestJson] = await Promise.all([
fs.readJson(paths.package),
fs.readJson(paths.manifest),
]);
await fs.writeJson(
paths.manifest,
{ ...manifestJson, version: packageJson.version },
{ spaces: 2 }
);
return normalize(paths.manifest);
};
exports.updatePackageLockVersion = async () => {
const [packageJson, packageLockJson] = await Promise.all([
fs.readJson(paths.package),
fs.readJson(paths.packageLock),
]);
await fs.writeJson(
paths.packageLock,
{ ...packageLockJson, version: packageJson.version },
{ spaces: 2 }
);
return normalize(paths.packageLock);
};
exports.copyFile = async (path) => {
await fs.copy(path, join(outputDirectory, path), { recursive: true });
};
exports.removeFile = async (path) => {
await fs.remove(join(outputDirectory, path));
};