mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Implement inputFile.readAndWatchFile.
This only works for files contained within the source root of the current app or package.
This commit is contained in:
@@ -8,7 +8,7 @@ var linker = require('./linker.js');
|
||||
var util = require('util');
|
||||
var _ = require('underscore');
|
||||
var Profile = require('../tool-env/profile.js').Profile;
|
||||
import {sha1} from '../fs/watch.js';
|
||||
import {sha1, readAndWatchFile} from '../fs/watch.js';
|
||||
import LRU from 'lru-cache';
|
||||
import Fiber from 'fibers';
|
||||
import {sourceMapLength} from '../utils/utils.js';
|
||||
@@ -256,6 +256,19 @@ class InputFile extends buildPluginModule.InputFile {
|
||||
return self._resourceSlot.inputResource.fileOptions || {};
|
||||
}
|
||||
|
||||
readAndWatchFile(path) {
|
||||
const sourceRoot = this.getSourceRoot();
|
||||
const relPath = files.pathRelative(sourceRoot, path);
|
||||
if (relPath.startsWith("..")) {
|
||||
throw new Error(
|
||||
`Attempting to read file outside ${
|
||||
this.getPackageName() || "the app"}: ${path}`
|
||||
);
|
||||
}
|
||||
const sourceBatch = this._resourceSlot.packageSourceBatch;
|
||||
return readAndWatchFile(sourceBatch.unibuild.watchSet, path);
|
||||
}
|
||||
|
||||
// Search ancestor directories for control files (e.g. package.json,
|
||||
// .babelrc), and return the absolute path of the first one found, or
|
||||
// null if the search failed.
|
||||
|
||||
Reference in New Issue
Block a user