diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 6699179c06..3d36b1b7be 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -493,6 +493,39 @@ class FileManager extends Plugin { return this._deps.filesProviders['browser'] } + allPaths () { + const dirPaths = [] + + const findPaths = (path) => { + return new Promise((resolve, reject) => { + if (this.isDirectory(path)) { + if (!dirPaths.includes(path)) { + dirPaths.push(path) + console.log('adding .. ', path) + } + + this.readdir(path).then((ls) => { + const promises = Object.keys(ls).map((item, index) => { + const curPath = `browser/${item}` + if (ls[item].isDirectory) { + return findPaths(curPath) + } else { + return new Promise((resolve, reject) => { resolve() }) + } + }) + Promise.all(promises).then(() => { resolve(dirPaths) }) + }) + } else { + resolve(dirPaths) + } + }) + } + + const br = findPaths('browser') + const lh = findPaths('localhost') + return Promise.all([br, lh]) + } + saveCurrentFile () { var currentFile = this._deps.config.get('currentFile') if (currentFile && this.editor.current()) { diff --git a/src/app/files/fileProvider.js b/src/app/files/fileProvider.js index 4aaae8b637..ac6d1887b4 100644 --- a/src/app/files/fileProvider.js +++ b/src/app/files/fileProvider.js @@ -226,7 +226,7 @@ class FileProvider { if (files) { files.forEach(element => { const absPath = (path === '/' ? '' : path) + '/' + element - ret[absPath.indexOf('/') === 0 ? absPath.replace('/', '') : absPath] = { isDirectory: window.remixFileSystem.statSync(absPath).isDirectory() } + ret[absPath.indexOf('/') === 0 ? absPath.substr(1, absPath.length) : absPath] = { isDirectory: window.remixFileSystem.statSync(absPath).isDirectory() } // ^ ret does not accept path starting with '/' }) } diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 0bec6aaa8f..d25ddf47ff 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -486,8 +486,7 @@ module.exports = class TestTab extends ViewPlugin { } allPaths () { - const paths = ['browser', 'browser/test'] - return paths + return this.testTabLogic.allPaths() } render () { @@ -510,9 +509,12 @@ module.exports = class TestTab extends ViewPlugin { ${this.uiPathList} ` - let options = ['browser', 'browser/test'] // this.allPaths() - options.forEach((path) => { - this.uiPathList.appendChild(yo``) + this.allPaths().then((options) => { + console.log('options ', options, ' length is ', options.length) + options.forEach((path) => { + console.log('option ', path) + this.uiPathList.appendChild(yo``) + }) }) this.testsExecutionStopped.hidden = true @@ -523,7 +525,7 @@ module.exports = class TestTab extends ViewPlugin {
Test your smart contract in Solidity.
-Click on "Generate" to generate a sample test file in.
+Click on "Generate" to generate a sample test file in a:
${availablePaths}