A virtual file abstraction for. This is meant to be used as the file abstraction for normalize.
Goals:
Current limitations:
<script>s) are currently not supported.
Need to figure out a mechanism for those types of files.Creates a new file abstraction based on a URI.
A URI could have #s or ?s.
However, the file must be a local file.
If it's a remote file, download it first.
.filename - the filename of the file.
Unlike the URI, this property is dynamic and removes any #s and ?s in the name..dirname - the folder this file is located..basename - the basename of this file.
This property is dynamic, meaning you can set it, and the filename will be updated automatically..type - the current mime type of the file.
Set the current mime type of the file to keep track of the current transformations..exists - whether the file exists, defaulting to true..sourcemap - whether source maps are enabled, defaulting to true..static - whether this file changes over time (i.e. for a watching instance),
defaulting to false. Set this to true in production when you know
files aren't going to change.Check fs.stat() the file and get the sha256 sum of the file.
Adds the following properties:
.length - the byte length of the file.mtime - the modified time of the file as a Date..hash - the sha256 sum of the file as a Buffer.You should run this before running anything else.
Get the current contents of the file as a string.
Also sets it as .string.
If the string contains an inline source map, it will be removed and moved to .map.
Set a string as the current contents of the file after a transformation.
If the string contains an inline source map, it will be removed and moved to .map.
Get the current source map of the file, if any.
Set the source map of the file.
This should be set before file.string=.
If a previous source map exists, it will be applied to the newest source map.
Otherwise, the current string and .basename will be set as the source.
Check whether the file is stale.
If it is stale, then a new file object will be returned.
Being using the new file object instead of this one.
The file is stale if any of the following is true: