2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.automation.jsscripting.internal.fs.watch;
17 import org.openhab.core.OpenHAB;
18 import org.openhab.core.automation.module.script.rulesupport.loader.DependencyTracker;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * Tracks JS module dependencies
25 * @author Jonathan Gilbert - Initial contribution
27 public class JSDependencyTracker extends DependencyTracker {
29 private final Logger logger = LoggerFactory.getLogger(JSDependencyTracker.class);
31 public static final String LIB_PATH = String.join(File.separator, OpenHAB.getConfigFolder(), "automation", "js",
34 public JSDependencyTracker() {
38 public void activate() {
39 File directory = new File(LIB_PATH);
40 if (!directory.exists()) {
41 if (!directory.mkdirs()) {
42 logger.warn("Failed to create watched directory: {}", LIB_PATH);
44 } else if (directory.isFile()) {
45 logger.warn("Trying to watch directory {}, however it is a file", LIB_PATH);