UNPKG

1.48 kBJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * strict
8 * @format
9 */
10'use strict';
11
12var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
13
14var _toConsumableArray2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/toConsumableArray"));
15
16function execFile(cmd, args) {
17 return new Promise(function (resolve, reject) {
18 require("child_process").execFile(cmd, args, function (err) {
19 if (err) {
20 reject(err);
21 } else {
22 resolve();
23 }
24 });
25 });
26}
27/**
28 * An abstraction over the source control system to make it injectable.
29 */
30
31
32var SourceControlMercurial = {
33 addRemove: function () {
34 var _addRemove = _asyncToGenerator(function* (added, removed) {
35 // NOTE: Not using `hg addremove` as that has a bug when deleting a file
36 // that was just added, but not yet committed: T10711513
37 if (added.length > 0) {
38 yield execFile('hg', ['add'].concat((0, _toConsumableArray2["default"])(added)));
39 }
40
41 if (removed.length > 0) {
42 yield execFile('hg', ['forget'].concat((0, _toConsumableArray2["default"])(removed)));
43 }
44 });
45
46 return function addRemove(_x, _x2) {
47 return _addRemove.apply(this, arguments);
48 };
49 }()
50};
51module.exports = {
52 SourceControlMercurial: SourceControlMercurial
53};
\No newline at end of file