zarro 1.185.0 → 1.187.0

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.
@@ -1,20 +1,12 @@
1
1
  "use strict";
2
2
  (function () {
3
3
  const { currentShortSHA } = requireModule("git-sha");
4
- function timestamp() {
5
- const now = new Date(Date.now()), year = `${now.getFullYear()}`.substring(2), month = zeroPad(now.getMonth() + 1), day = zeroPad(now.getDate()), hour = zeroPad(now.getHours()), minute = zeroPad(now.getMinutes());
6
- return [
7
- year,
8
- month,
9
- day,
10
- hour,
11
- minute
12
- ].join("");
13
- }
14
- function zeroPad(i) {
15
- return i < 10 ? `0${i}` : `${i}`;
16
- }
4
+ const { timestamp } = requireModule("timestamp");
5
+ const options = {
6
+ fullYear: false,
7
+ includeSeconds: false
8
+ };
17
9
  module.exports = function generateVersionSuffix() {
18
- return `${timestamp()}.${currentShortSHA()}`;
10
+ return `${timestamp(options)}.${currentShortSHA()}`;
19
11
  };
20
12
  })();
@@ -1,53 +1,53 @@
1
- (function () {
2
- const
3
- gitFactory = require("simple-git"),
4
- resolveGitBranch = requireModule("resolve-git-branch"),
5
- resolveGitRemote = requireModule("resolve-git-remote"),
6
- gutil = requireModule("gulp-util");
7
-
8
- async function gitPush(
9
- dryRun,
10
- quiet,
11
- where
12
- ) {
13
- if (dryRun === undefined) {
14
- dryRun = {};
15
- }
16
- if (typeof dryRun === "object") {
17
- quiet = dryRun.quiet || false;
18
- where = dryRun.where || ".";
19
- dryRun = dryRun.dryRun || false;
20
- } else if (quiet !== undefined) {
21
- gutil.log.warn(
22
- gutil.colors.red(
23
- "depreciation warning: options for git-push should be sent via an object"
24
- )
25
- );
26
- }
27
- where = where || ".";
28
- quiet = !!quiet;
29
- const
30
- git = gitFactory(where),
31
- more = (where && where !== ".") ? ` (${ where })` : "";
32
- if (dryRun) {
33
- gutil.log(gutil.colors.green(`dry run: whould push local commits now${ more }...`));
34
- return Promise.resolve();
35
- }
36
- if (!quiet) {
37
- gutil.log(gutil.colors.green(`pushing local commits${ more }...`));
38
- }
39
- const
40
- remote = await resolveGitRemote(),
41
- branch = await resolveGitBranch();
42
- if (remote && branch) {
43
- await git.push(
44
- remote,
45
- branch, [
46
- "-u" // we're probably already tracking, but this will help a new branch
47
- ]
48
- );
49
- }
50
- }
51
-
52
- module.exports = gitPush;
53
- })();
1
+ (function () {
2
+ const
3
+ gitFactory = require("simple-git"),
4
+ resolveGitBranch = requireModule("resolve-git-branch"),
5
+ resolveGitRemote = requireModule("resolve-git-remote"),
6
+ gutil = requireModule("gulp-util");
7
+
8
+ async function gitPush(
9
+ dryRun,
10
+ quiet,
11
+ where
12
+ ) {
13
+ if (dryRun === undefined) {
14
+ dryRun = {};
15
+ }
16
+ if (typeof dryRun === "object") {
17
+ quiet = dryRun.quiet || false;
18
+ where = dryRun.where || ".";
19
+ dryRun = dryRun.dryRun || false;
20
+ } else if (quiet !== undefined) {
21
+ gutil.log.warn(
22
+ gutil.colors.red(
23
+ "depreciation warning: options for git-push should be sent via an object"
24
+ )
25
+ );
26
+ }
27
+ where = where || ".";
28
+ quiet = !!quiet;
29
+ const
30
+ git = gitFactory(where),
31
+ more = (where && where !== ".") ? ` (${ where })` : "";
32
+ if (dryRun) {
33
+ gutil.log(gutil.colors.green(`dry run: whould push local commits now${ more }...`));
34
+ return Promise.resolve();
35
+ }
36
+ if (!quiet) {
37
+ gutil.log(gutil.colors.green(`pushing local commits${ more }...`));
38
+ }
39
+ const
40
+ remote = await resolveGitRemote(),
41
+ branch = await resolveGitBranch();
42
+ if (remote && branch) {
43
+ await git.push(
44
+ remote,
45
+ branch, [
46
+ "-u" // we're probably already tracking, but this will help a new branch
47
+ ]
48
+ );
49
+ }
50
+ }
51
+
52
+ module.exports = gitPush;
53
+ })();
@@ -33,12 +33,12 @@
33
33
  for (const item of negatives) {
34
34
  possibleNegatives.push(item);
35
35
  }
36
- throw new Error(`${value} is not a valid flag value.
37
- Try one of:
38
- - accepted truthy values:
39
- ${possiblePositives.join(", ")}
40
- - accepted falsey values:
41
- ${possibleNegatives.join(", ")}
36
+ throw new Error(`${value} is not a valid flag value.
37
+ Try one of:
38
+ - accepted truthy values:
39
+ ${possiblePositives.join(", ")}
40
+ - accepted falsey values:
41
+ ${possibleNegatives.join(", ")}
42
42
  `);
43
43
  }
44
44
  module.exports = {
@@ -99,7 +99,7 @@
99
99
  throw new ZarroError("MONO is required to run nuget restore on this platform");
100
100
  }
101
101
  const baseFolder = findNpmBase();
102
- const script = `#!/bin/sh
102
+ const script = `#!/bin/sh
103
103
  mono ${path.resolve(nugetPath)} $@`;
104
104
  const scriptPath = path.join(baseFolder, "node_modules", ".bin", "mono-nuget");
105
105
  writeFileSync(scriptPath, script, { encoding: "utf-8" });
@@ -91,6 +91,21 @@ ${tempFileContents}
91
91
  const result = new SystemResult(`${exe}`, programArgs, undefined, [], []);
92
92
  return new Promise((resolve, reject) => {
93
93
  const child = child_process.spawn(exe, programArgs, spawnOptions);
94
+ if (!!options) {
95
+ const optsWithKill = options;
96
+ optsWithKill.kill = (signal) => {
97
+ destroyPipesOn(child);
98
+ child.kill(signal);
99
+ };
100
+ if (optsWithKill === null || optsWithKill === void 0 ? void 0 : optsWithKill.onChildSpawned) {
101
+ try {
102
+ optsWithKill.onChildSpawned(child, optsWithKill);
103
+ }
104
+ catch (e) {
105
+ // suppress
106
+ }
107
+ }
108
+ }
94
109
  const stdoutFn = typeof opts.stdout === "function" ? opts.stdout : noop;
95
110
  const stderrFn = typeof opts.stderr === "function" ? opts.stderr : noop;
96
111
  const stdoutLineBuffer = new LineBuffer(s => {
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ (function () {
3
+ function timestamp(opts) {
4
+ var _a;
5
+ opts = opts || {};
6
+ if (!opts.delimiter) {
7
+ opts.delimiter = "";
8
+ }
9
+ if (opts.includeSeconds === undefined) {
10
+ opts.includeSeconds = true;
11
+ }
12
+ if (opts.includeMilliseconds === undefined) {
13
+ opts.includeMilliseconds = false;
14
+ }
15
+ if (opts.fullYear === undefined) {
16
+ opts.fullYear = true;
17
+ }
18
+ const now = (_a = opts.forDate) !== null && _a !== void 0 ? _a : new Date();
19
+ let yearString = `${now.getFullYear()}`;
20
+ if (!opts.fullYear) {
21
+ yearString = yearString.substring(2, 4);
22
+ }
23
+ const parts = [
24
+ yearString,
25
+ `${now.getMonth() + 1}`.padStart(2, "0"),
26
+ `${now.getDate()}`.padStart(2, "0"),
27
+ `${now.getHours()}`.padStart(2, "0"),
28
+ `${now.getMinutes()}`.padStart(2, "0")
29
+ ];
30
+ if (opts.includeSeconds) {
31
+ parts.push(`${now.getSeconds()}`.padStart(2, "0"));
32
+ }
33
+ if (opts.includeMilliseconds) {
34
+ parts.push(`${now.getMilliseconds()}`.padStart(3, "0"));
35
+ }
36
+ return parts.join(opts.delimiter);
37
+ }
38
+ module.exports = {
39
+ timestamp
40
+ };
41
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarro",
3
- "version": "1.185.0",
3
+ "version": "1.187.0",
4
4
  "description": "Some glue to make gulp easier, perhaps even zero- or close-to-zero-conf",
5
5
  "bin": {
6
6
  "zarro": "index.js"
package/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import { StatsBase } from "fs";
5
5
  import { Stream, Transform } from "stream";
6
6
  import ansiColors, { StyleFunction } from "ansi-colors";
7
7
  import { RimrafOptions } from "./gulp-tasks/modules/rimraf";
8
- import { ExecFileOptionsWithBufferEncoding } from "child_process";
8
+ import { ChildProcess, ExecFileOptionsWithBufferEncoding } from "child_process";
9
9
  import * as vinyl from "vinyl";
10
10
  import { BufferFile } from "vinyl";
11
11
  // noinspection ES6PreferShortImport
@@ -1095,6 +1095,7 @@ declare global {
1095
1095
  * io writer or the result from after spawn completes
1096
1096
  */
1097
1097
  suppressOutput?: boolean;
1098
+
1098
1099
  }
1099
1100
 
1100
1101
  interface SystemOptions {
@@ -1134,6 +1135,17 @@ declare global {
1134
1135
  * / error as the first argument, with the exe set to either cmd or sh
1135
1136
  */
1136
1137
  keepTempFiles?: boolean;
1138
+
1139
+ // gain direct access to the child process as
1140
+ // soon as it spawns
1141
+ onChildSpawned?: (child: ChildProcess, originalOptions: SystemOptionsWithKill) => void;
1142
+
1143
+ }
1144
+
1145
+ interface SystemOptionsWithKill extends SystemOptions {
1146
+ // this function will be filled in for you once the
1147
+ // child process has started
1148
+ kill: (signal?: NodeJS.Signals | number) => void;
1137
1149
  }
1138
1150
 
1139
1151
  /**
@@ -2189,5 +2201,16 @@ declare global {
2189
2201
  forget(key: string): void;
2190
2202
  clear(): void;
2191
2203
  }
2204
+
2205
+ export interface TimestampOptions {
2206
+ delimiter?: string;
2207
+ includeSeconds?: boolean;
2208
+ includeMilliseconds?: boolean;
2209
+ fullYear?: boolean;
2210
+ forDate?: Date;
2211
+ }
2212
+ interface Timestamp {
2213
+ timestamp: (opts?: TimestampOptions) => string;
2214
+ }
2192
2215
  }
2193
2216