當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mock-fs.symlink函數代碼示例

本文整理匯總了TypeScript中mock-fs.symlink函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript symlink函數的具體用法?TypeScript symlink怎麽用?TypeScript symlink使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了symlink函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it("returns stats even if the file is a borken symlink", async() => {
     mockFs({
         "/broken-symlink": mockFs.symlink({
             path: "non-existing-file"
         })
     });
     const stats = await lstat(resolveFile("/", "/broken-symlink"))
     expect(stats).to.exist;
 });
開發者ID:H1net,項目名稱:black-screen,代碼行數:9,代碼來源:common_spec.ts

示例2: f

function f() {
	mock({
		'some/dir': {
			'regular-file': 'file contents',
			'a-symlink': mock.symlink({
				path: 'regular-file'
			})
		}
	});
}
開發者ID:ClearboxSystems,項目名稱:DefinitelyTyped,代碼行數:10,代碼來源:mock-fs-tests.ts

示例3: it

    it('should handle changes via symbolic links', () => {
      let testDir = {
        'orig_path': {
          'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
          'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}),
          'subdir-1': {
            'file-1.1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
          }
        },
        'symlinks': {
          'file-1.txt': mockfs.symlink({path: '../orig_path/file-1.txt'}),
          'file-2.txt': mockfs.symlink({path: '../orig_path/file-2.txt'}),
          'subdir-1':
              {'file-1.1.txt': mockfs.symlink({path: '../../orig_path/subdir-1/file-1.1.txt'})}
        }
      };
      mockfs(testDir);

      let differ = new TreeDiffer('testLabel', 'symlinks');

      let diffResult = differ.diffTree();

      expect(diffResult.addedPaths).toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);

      // change two files
      testDir['orig_path']['file-1.txt'] =
          mockfs.file({content: 'new content', mtime: new Date(1000)});
      testDir['orig_path']['subdir-1']['file-1.1.txt'] =
          mockfs.file({content: 'file-1.1.txt content', mtime: new Date(9999)});
      mockfs(testDir);

      diffResult = differ.diffTree();

      expect(diffResult.addedPaths).toEqual([]);
      expect(diffResult.changedPaths).toEqual(['file-1.txt', 'subdir-1/file-1.1.txt']);
      expect(diffResult.removedPaths).toEqual([]);

      // change one file
      testDir['orig_path']['file-1.txt'] =
          mockfs.file({content: 'super new', mtime: new Date(1000)});
      mockfs(testDir);

      diffResult = differ.diffTree();
      expect(diffResult.changedPaths).toEqual(['file-1.txt']);

      // remove a link
      delete testDir['orig_path']['file-1.txt'];
      mockfs(testDir);

      diffResult = differ.diffTree();
      expect(diffResult.addedPaths).toEqual([]);
      expect(diffResult.changedPaths).toEqual([]);
      expect(diffResult.removedPaths).toEqual(['file-1.txt']);

      // don't report it as a removal twice
      mockfs(testDir);

      diffResult = differ.diffTree();
      expect(diffResult.changedPaths).toEqual([]);
      expect(diffResult.removedPaths).toEqual([]);

      // re-add it.
      testDir['orig_path']['file-1.txt'] =
          mockfs.file({content: 'super new', mtime: new Date(1000)});
      mockfs(testDir);

      diffResult = differ.diffTree();
      expect(diffResult.addedPaths).toEqual(['file-1.txt']);
      expect(diffResult.changedPaths).toEqual([]);
      expect(diffResult.removedPaths).toEqual([]);
    });
開發者ID:AsherBarak,項目名稱:angular,代碼行數:71,代碼來源:tree-differ.spec.ts

示例4: createMockFileSystem

 function createMockFileSystem() {
   mockFs({
     '/sub_entry_points': {
       'common': {
         'package.json': createPackageJson('common'),
         'common.metadata.json': 'metadata info',
         'http': {
           'package.json': createPackageJson('http'),
           'http.metadata.json': 'metadata info',
           'testing': {
             'package.json': createPackageJson('testing'),
             'testing.metadata.json': 'metadata info',
           },
         },
         'testing': {
           'package.json': createPackageJson('testing'),
           'testing.metadata.json': 'metadata info',
         },
       },
     },
     '/namespaced': {
       '@angular': {
         'common': {
           'package.json': createPackageJson('common'),
           'common.metadata.json': 'metadata info',
           'http': {
             'package.json': createPackageJson('http'),
             'http.metadata.json': 'metadata info',
             'testing': {
               'package.json': createPackageJson('testing'),
               'testing.metadata.json': 'metadata info',
             },
           },
           'testing': {
             'package.json': createPackageJson('testing'),
             'testing.metadata.json': 'metadata info',
           },
         },
       },
     },
     '/no_packages': {'should_not_be_found': {}},
     '/no_valid_entry_points': {
       'some_package': {
         'package.json': '{}',
       },
     },
     '/dotted_folders': {
       '.common': {
         'package.json': createPackageJson('common'),
         'common.metadata.json': 'metadata info',
       },
     },
     '/symlinked_folders': {
       'common': mockFs.symlink({path: '/sub_entry_points/common'}),
     },
     '/nested_node_modules': {
       'outer': {
         'package.json': createPackageJson('outer'),
         'outer.metadata.json': 'metadata info',
         'node_modules': {
           'inner': {
             'package.json': createPackageJson('inner'),
             'inner.metadata.json': 'metadata info',
           },
         },
       },
     },
   });
 }
開發者ID:jorgeucano,項目名稱:angular,代碼行數:69,代碼來源:entry_point_finder_spec.ts


注:本文中的mock-fs.symlink函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。