UNPKG

@communities-webruntime/services

Version:

If you would like to run Lightning Web Runtime without the CLI, we expose some of our programmatic APIs available in Node.js. If you're looking for the CLI documentation [you can find that here](https://www.npmjs.com/package/@communities-webruntime/cli).

49 lines 1.7 kB
"use strict"; /** @hidden */ /** * Copyright (c) 2019, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const chokidar_1 = __importDefault(require("chokidar")); const folder_hash_1 = require("folder-hash"); const options = { algo: 'md5', encoding: 'hex', }; async function doHash(target) { return (await folder_hash_1.hashElement(target, options)).hash; } /** * Gets a folder hash as an observable. * * @param {string} target The directory to compute the version key for * @returns An observable that will notify observers when the folder hash changes */ async function folderHash(target) { // Chokidar/picomatch don't like relative paths starting with `./`, see #857 const absoluteTarget = path_1.default.resolve(target); const hash = await doHash(absoluteTarget); return { subscribe(observer) { observer.next(hash); const watcher = chokidar_1.default.watch(absoluteTarget).on('change', async () => { const newHash = await doHash(absoluteTarget); observer.next(newHash); }); return { unsubscribe: () => { watcher.close(); }, }; }, }; } exports.default = folderHash; //# sourceMappingURL=observable-folder-hash.js.map