generate the list of paths

pull/262/head
LianaHus 5 years ago committed by yann300
parent 5fbdcbadd7
commit e9e9ff36e2
  1. 33
      src/app/files/fileManager.js
  2. 2
      src/app/files/fileProvider.js
  3. 14
      src/app/tabs/test-tab.js
  4. 5
      src/app/tabs/testTab/testTab.js

@ -493,6 +493,39 @@ class FileManager extends Plugin {
return this._deps.filesProviders['browser'] 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 () { saveCurrentFile () {
var currentFile = this._deps.config.get('currentFile') var currentFile = this._deps.config.get('currentFile')
if (currentFile && this.editor.current()) { if (currentFile && this.editor.current()) {

@ -226,7 +226,7 @@ class FileProvider {
if (files) { if (files) {
files.forEach(element => { files.forEach(element => {
const absPath = (path === '/' ? '' : path) + '/' + 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 '/' // ^ ret does not accept path starting with '/'
}) })
} }

@ -486,8 +486,7 @@ module.exports = class TestTab extends ViewPlugin {
} }
allPaths () { allPaths () {
const paths = ['browser', 'browser/test'] return this.testTabLogic.allPaths()
return paths
} }
render () { render () {
@ -510,9 +509,12 @@ module.exports = class TestTab extends ViewPlugin {
${this.uiPathList} ${this.uiPathList}
</div> </div>
` `
let options = ['browser', 'browser/test'] // this.allPaths() this.allPaths().then((options) => {
options.forEach((path) => { console.log('options ', options, ' length is ', options.length)
this.uiPathList.appendChild(yo`<option>${path}</option>`) options.forEach((path) => {
console.log('option ', path)
this.uiPathList.appendChild(yo`<option>${path}</option>`)
})
}) })
this.testsExecutionStopped.hidden = true this.testsExecutionStopped.hidden = true
@ -523,7 +525,7 @@ module.exports = class TestTab extends ViewPlugin {
<div class="${css.testTabView} px-2" id="testView"> <div class="${css.testTabView} px-2" id="testView">
<div class="${css.infoBox}"> <div class="${css.infoBox}">
<p class="text-lg"> Test your smart contract in Solidity.</p> <p class="text-lg"> Test your smart contract in Solidity.</p>
<p> Click on "Generate" to generate a sample test file in.</p> <p> Click on "Generate" to generate a sample test file in a:</p>
${availablePaths} ${availablePaths}
</div> </div>
<div class="${css.tests}"> <div class="${css.tests}">

@ -1,6 +1,7 @@
const helper = require('../../../lib/helper.js') const helper = require('../../../lib/helper.js')
const modalDialogCustom = require('../../ui/modal-dialog-custom') const modalDialogCustom = require('../../ui/modal-dialog-custom')
const remixPath = require('path') const remixPath = require('path')
class TestTabLogic { class TestTabLogic {
constructor (fileManager) { constructor (fileManager) {
@ -31,6 +32,10 @@ class TestTabLogic {
}) })
} }
allPaths () {
return this.fileManager.allPaths()
}
async getTests (cb) { async getTests (cb) {
if (!this.currentPath) return cb(null, []) if (!this.currentPath) return cb(null, [])
const provider = this.fileManager.fileProviderOf(this.currentPath) const provider = this.fileManager.fileProviderOf(this.currentPath)

Loading…
Cancel
Save