@uirouter/publish-scripts 2.6.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/util.js CHANGED
@@ -1,50 +1,50 @@
1
- "use strict";
2
-
3
- const findParentDir = require('find-parent-dir');
4
- const fs = require('fs');
5
- require('shelljs/global');
6
-
7
- function packageDir() {
8
- const packageDir = findParentDir.sync(process.cwd(), 'package.json');
9
- cd(packageDir);
10
- }
11
-
12
- function ensureCleanMaster(branch) {
13
- branch = branch || 'master';
14
- if (exec('git symbolic-ref HEAD').stdout.trim() !== `refs/heads/${branch}`)
15
- throw new Error(`Not on ${branch} branch, aborting`);
16
- if (exec('git status --porcelain').stdout.trim() !== '')
17
- throw new Error('Working copy is dirty, aborting');
18
- }
19
-
20
- function _exec(command, silent) {
21
- if (!silent) {
22
- echo(command);
23
- echo();
24
- }
25
- var result = exec(command, { silent: !!silent });
26
- if (result.code === 0) return result;
27
- echo(`cwd: ${process.cwd()}`);
28
- echo(`Aborting; non-zero return value (${result.code}) from: ${command}`);
29
- console.error(result.stderr);
30
- exit(result.code)
31
- }
32
-
33
- function asJson (obj) { return JSON.stringify(obj, null, 2); }
34
-
35
- let ensure = (type) => (path) => {
36
- let is = false;
37
- try { is = fs.lstatSync(path)['is' + type](); } catch (e) { console.log(e); }
38
- if (!is) echo(`Not a ${type}: ${path}`) && exit(-3);
39
- };
40
- let assertDir = ensure('Directory');
41
- let assertFile = ensure('File');
42
-
43
- module.exports = {
44
- ensureCleanMaster: ensureCleanMaster,
45
- _exec: _exec,
46
- asJson: asJson,
47
- assertDir: assertDir,
48
- assertFile: assertFile,
49
- packageDir: packageDir,
50
- };
1
+ "use strict";
2
+
3
+ const findParentDir = require('find-parent-dir');
4
+ const fs = require('fs');
5
+ require('shelljs/global');
6
+
7
+ function packageDir() {
8
+ const packageDir = findParentDir.sync(process.cwd(), 'package.json');
9
+ cd(packageDir);
10
+ }
11
+
12
+ function ensureCleanMaster(branch) {
13
+ branch = branch || 'master';
14
+ if (exec('git symbolic-ref HEAD').stdout.trim() !== `refs/heads/${branch}`)
15
+ throw new Error(`Not on ${branch} branch, aborting`);
16
+ if (exec('git status --porcelain').stdout.trim() !== '')
17
+ throw new Error('Working copy is dirty, aborting');
18
+ }
19
+
20
+ function _exec(command, silent) {
21
+ if (!silent) {
22
+ echo(command);
23
+ echo();
24
+ }
25
+ var result = exec(command, { silent: !!silent });
26
+ if (result.code === 0) return result;
27
+ echo(`cwd: ${process.cwd()}`);
28
+ echo(`Aborting; non-zero return value (${result.code}) from: ${command}`);
29
+ console.error(result.stderr);
30
+ exit(result.code)
31
+ }
32
+
33
+ function asJson (obj) { return JSON.stringify(obj, null, 2); }
34
+
35
+ let ensure = (type) => (path) => {
36
+ let is = false;
37
+ try { is = fs.lstatSync(path)['is' + type](); } catch (e) { console.log(e); }
38
+ if (!is) echo(`Not a ${type}: ${path}`) && exit(-3);
39
+ };
40
+ let assertDir = ensure('Directory');
41
+ let assertFile = ensure('File');
42
+
43
+ module.exports = {
44
+ ensureCleanMaster: ensureCleanMaster,
45
+ _exec: _exec,
46
+ asJson: asJson,
47
+ assertDir: assertDir,
48
+ assertFile: assertFile,
49
+ packageDir: packageDir,
50
+ };