@google/clasp
Version:
Develop Apps Script Projects locally
35 lines (34 loc) • 1.54 kB
JavaScript
import { Command } from 'commander';
import { intl } from '../intl.js';
import { withSpinner } from './utils.js';
export const command = new Command('show-file-status')
.alias('status')
.description('Lists files that will be pushed by clasp')
.option('--json', 'Show status in JSON form')
.action(async function (options) {
var _a;
const clasp = this.opts().clasp;
const outputAsJson = (_a = options === null || options === void 0 ? void 0 : options.json) !== null && _a !== void 0 ? _a : false;
const spinnerMsg = intl.formatMessage({ id: "3pOneN", defaultMessage: [{ type: 0, value: "Analyzing project files..." }] });
const [filesToPush, untrackedFiles] = await withSpinner(spinnerMsg, async () => {
return await Promise.all([clasp.files.collectLocalFiles(), clasp.files.getUntrackedFiles()]);
});
if (outputAsJson) {
const json = JSON.stringify({
filesToPush: filesToPush.map(f => f.localPath),
untrackedFiles,
});
console.log(json);
return;
}
const trackedMsg = intl.formatMessage({ id: "eSUzih", defaultMessage: [{ type: 0, value: "Tracked files:" }] });
console.log(trackedMsg);
for (const file of filesToPush) {
console.log(`└─ ${file.localPath}`);
}
const untrackedMsg = intl.formatMessage({ id: "G6KFcG", defaultMessage: [{ type: 0, value: "Untracked files:" }] });
console.log(untrackedMsg);
for (const file of untrackedFiles) {
console.log(`└─ ${file}`);
}
});