예제 #1
0
        public static TSProject FindInfoForModule(IDirectoryCache projectDir, IDirectoryCache dir, IDiskCache diskCache,
                                                  ILogger logger,
                                                  string moduleName,
                                                  out string diskName)
        {
            if (projectDir.TryGetChildNoVirtual("node_modules") is IDirectoryCache pnmdir)
            {
                diskCache.UpdateIfNeeded(pnmdir);
                if (pnmdir.TryGetChild(moduleName, true) is IDirectoryCache mdir)
                {
                    diskName = mdir.Name;
                    diskCache.UpdateIfNeeded(mdir);
                    return(Get(mdir, diskCache, logger, diskName));
                }
            }

            while (dir != null)
            {
                if (diskCache.TryGetItem(PathUtils.Join(dir.FullPath, "node_modules")) is IDirectoryCache nmdir)
                {
                    diskCache.UpdateIfNeeded(nmdir);
                    if (nmdir.TryGetChild(moduleName, true) is IDirectoryCache mdir)
                    {
                        diskName = mdir.Name;
                        diskCache.UpdateIfNeeded(mdir);
                        return(Get(mdir, diskCache, logger, diskName));
                    }
                }

                dir = dir.Parent;
            }

            diskName = null;
            return(null);
        }
예제 #2
0
        public bool Run(string projectDir, bool generateSpritesFile)
        {
            var projDir = _cache.TryGetItem(projectDir) as IDirectoryCache;

            if (projDir == null)
            {
                return(false);
            }
            _cache.UpdateIfNeeded(projDir);
            var assetsDir = projDir.TryGetChild(_assetsDirName) as IDirectoryCache;

            if (assetsDir == null)
            {
                return(false);
            }
            var srcPath = PathUtils.Join(projectDir, _srcDirName);

            var assets = InspectAssets(assetsDir, srcPath);
            var assetsContentBuilder = new AssetsContentBuilder();

            assetsContentBuilder.Build(assets);
            var changed = WriteContent(srcPath, _assetsFileName, assetsContentBuilder.Content, projectDir);

            if (generateSpritesFile)
            {
                var spritesContentBuilder = new SpritesContentBuilder();
                spritesContentBuilder.Build(assets);
                changed |= WriteContent(srcPath, _spritesFileName, spritesContentBuilder.Content, projectDir);
            }
            return(changed);
        }
예제 #3
0
        public void UpgradeAll(IDirectoryCache projectDirectory)
        {
            _diskCache.UpdateIfNeeded(projectDirectory);
            File.Delete(PathUtils.Join(projectDirectory.FullPath, "package-lock.json"));
            var dirToDelete = projectDirectory.TryGetChild("node_modules") as IDirectoryCache;

            RecursiveDelete(dirToDelete);
            Install(projectDirectory);
        }
예제 #4
0
 void RecursiveFileSearch(IDirectoryCache owner, IDiskCache diskCache, Regex fileRegex, List <string> res)
 {
     diskCache.UpdateIfNeeded(owner);
     if (owner.IsInvalid)
     {
         return;
     }
     foreach (var item in owner)
     {
         if (item is IDirectoryCache)
         {
             if (item.Name == "node_modules")
             {
                 continue;
             }
             if (item.IsInvalid)
             {
                 continue;
             }
             RecursiveFileSearch(item as IDirectoryCache, diskCache, fileRegex, res);
         }
         else if (item is IFileCache && !item.IsVirtual)
         {
             if (fileRegex.IsMatch(item.Name))
             {
                 res.Add(item.FullPath);
             }
         }
     }
 }
예제 #5
0
 public static TSProject FindInfoForModule(IDirectoryCache dir, IDiskCache diskCache, string moduleName, out string diskName)
 {
     while (!dir.IsFake)
     {
         diskCache.UpdateIfNeeded(dir);
         var nmdir = dir.TryGetChild("node_modules") as IDirectoryCache;
         if (nmdir != null)
         {
             diskCache.UpdateIfNeeded(nmdir);
             var mdir = nmdir.TryGetChild(moduleName) as IDirectoryCache;
             if (mdir != null)
             {
                 diskName = mdir.Name;
                 diskCache.UpdateIfNeeded(mdir);
                 return(Get(mdir, diskCache));
             }
         }
         dir = dir.Parent;
     }
     diskName = null;
     return(null);
 }