126 lines
4.6 KiB
JavaScript
126 lines
4.6 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.openProjectInEditorAsync = exports.openFileInEditorAsync = exports.openConsoleAsync = exports.openFolderAsync = undefined;
|
|
|
|
let openFolderAsync = exports.openFolderAsync = (() => {
|
|
var _ref = _asyncToGenerator(function* (dir) {
|
|
if (process.platform === 'darwin') {
|
|
return yield osascript.openFinderToFolderAsync(dir);
|
|
} else if (process.platform === 'win32') {
|
|
return yield (0, (_spawnAsync || _load_spawnAsync()).default)('explorer', [dir]);
|
|
}
|
|
});
|
|
|
|
return function openFolderAsync(_x) {
|
|
return _ref.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
let openConsoleAsync = exports.openConsoleAsync = (() => {
|
|
var _ref2 = _asyncToGenerator(function* (dir) {
|
|
if (process.platform === 'darwin') {
|
|
return yield osascript.openFolderInTerminalAppAsync(dir);
|
|
} else if (process.platform === 'win32') {
|
|
_child_process.default.exec(`start cmd /K "cd /d ${dir}"`);
|
|
}
|
|
});
|
|
|
|
return function openConsoleAsync(_x2) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
let openFileInEditorAsync = exports.openFileInEditorAsync = (() => {
|
|
var _ref3 = _asyncToGenerator(function* (path) {
|
|
if (process.platform === 'darwin') {
|
|
// This will use the ENV var $EXPO_EDITOR if set, or else will try various
|
|
// popular editors, looking for one that is open, or if none are, one that is installed
|
|
yield (_Binaries || _load_Binaries()).sourceBashLoginScriptsAsync();
|
|
return yield osascript.openInEditorAsync(path, process.env.EXPO_EDITOR);
|
|
} else if (process.platform === 'win32') {
|
|
throw new (_XDLError || _load_XDLError()).default((_ErrorCode || _load_ErrorCode()).default.PLATFORM_NOT_SUPPORTED, 'openFileInEditorAsync not supported');
|
|
}
|
|
});
|
|
|
|
return function openFileInEditorAsync(_x3) {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
let openProjectInEditorAsync = exports.openProjectInEditorAsync = (() => {
|
|
var _ref4 = _asyncToGenerator(function* (dir) {
|
|
if (process.platform === 'darwin') {
|
|
// This will use the ENV var $EXPO_EDITOR if set, or else will try various
|
|
// popular editors, looking for one that is open, or if none are, one that is installed
|
|
yield (_Binaries || _load_Binaries()).sourceBashLoginScriptsAsync();
|
|
return yield osascript.openInEditorAsync(dir, process.env.EXPO_EDITOR);
|
|
} else if (process.platform === 'win32') {
|
|
throw new (_XDLError || _load_XDLError()).default((_ErrorCode || _load_ErrorCode()).default.PLATFORM_NOT_SUPPORTED, 'openProjectInEditorAsync not supported');
|
|
}
|
|
});
|
|
|
|
return function openProjectInEditorAsync(_x4) {
|
|
return _ref4.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
exports.openFolderName = openFolderName;
|
|
exports.openConsoleName = openConsoleName;
|
|
|
|
var _child_process = _interopRequireDefault(require('child_process'));
|
|
|
|
var _spawnAsync;
|
|
|
|
function _load_spawnAsync() {
|
|
return _spawnAsync = _interopRequireDefault(require('@expo/spawn-async'));
|
|
}
|
|
|
|
var _Binaries;
|
|
|
|
function _load_Binaries() {
|
|
return _Binaries = _interopRequireWildcard(require('./Binaries'));
|
|
}
|
|
|
|
var _ErrorCode;
|
|
|
|
function _load_ErrorCode() {
|
|
return _ErrorCode = _interopRequireDefault(require('./ErrorCode'));
|
|
}
|
|
|
|
var _XDLError;
|
|
|
|
function _load_XDLError() {
|
|
return _XDLError = _interopRequireDefault(require('./XDLError'));
|
|
}
|
|
|
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
|
|
|
let osascript;
|
|
if (process.platform === 'darwin') {
|
|
osascript = require('@expo/osascript');
|
|
}
|
|
|
|
function openFolderName() {
|
|
if (process.platform === 'darwin') {
|
|
return 'Show in Finder';
|
|
} else if (process.platform === 'win32') {
|
|
return 'Show in File Explorer';
|
|
}
|
|
}
|
|
|
|
function openConsoleName() {
|
|
if (process.platform === 'darwin') {
|
|
return 'Open in Terminal';
|
|
} else if (process.platform === 'win32') {
|
|
return 'Open in Cmd';
|
|
}
|
|
}
|
|
//# sourceMappingURL=__sourcemaps__/FileSystem.js.map
|